Skip to main content
added 23 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

To have a recursive extraction with proper tree structure while unzipping we can use while [ "find . -type f -name '*.zip' | wc -l" -gt 0 ] do find . -name '.zip' -exec sh -c 'unzip -o -d "${0%.}" "$0"' '{}' ';' -exec rm -- '{}' ; done

find . -name '.zip': Finds the files with .zip extention in current directory unzip -o : unzips file and overides if there is a file with same name -d "${0%.}" : creates directory with the same name of the zip file

while [ "`find . -type f -name '*.zip' | wc -l`" -gt 0 ]
do
   find . -name '*.zip' -exec sh -c 'unzip -o -d "${0%.*}" "$0"' '{}' ';' -exec rm -- '{}' \;
done
  • find . -name '*.zip': Finds the files with .zip extension in current directory
  • unzip -o: unzips file and overrides if there is a file with same name
  • -d "${0%.*}": creates directory with the same name of the zip file

To have a recursive extraction with proper tree structure while unzipping we can use while [ "find . -type f -name '*.zip' | wc -l" -gt 0 ] do find . -name '.zip' -exec sh -c 'unzip -o -d "${0%.}" "$0"' '{}' ';' -exec rm -- '{}' ; done

find . -name '.zip': Finds the files with .zip extention in current directory unzip -o : unzips file and overides if there is a file with same name -d "${0%.}" : creates directory with the same name of the zip file

To have a recursive extraction with proper tree structure while unzipping we can use

while [ "`find . -type f -name '*.zip' | wc -l`" -gt 0 ]
do
   find . -name '*.zip' -exec sh -c 'unzip -o -d "${0%.*}" "$0"' '{}' ';' -exec rm -- '{}' \;
done
  • find . -name '*.zip': Finds the files with .zip extension in current directory
  • unzip -o: unzips file and overrides if there is a file with same name
  • -d "${0%.*}": creates directory with the same name of the zip file
Post Undeleted by sonika b v
Post Deleted by sonika b v
Source Link

To have a recursive extraction with proper tree structure while unzipping we can use while [ "find . -type f -name '*.zip' | wc -l" -gt 0 ] do find . -name '.zip' -exec sh -c 'unzip -o -d "${0%.}" "$0"' '{}' ';' -exec rm -- '{}' ; done

find . -name '.zip': Finds the files with .zip extention in current directory unzip -o : unzips file and overides if there is a file with same name -d "${0%.}" : creates directory with the same name of the zip file