Created
December 14, 2023 10:07
-
-
Save koraysels/e39658b7d3d4d26abcd60de6a7467291 to your computer and use it in GitHub Desktop.
unzip all zip files in folder and use the zip archive name as the folder root
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for zipFile in *.zip; do | |
fileName=$(basename "$zipFile" .zip) | |
echo "Extracting $zipFile..." | |
unzip -q "$zipFile" -d "$fileName" | |
newName=$(echo "$fileName" | cut -d '_' -f 1) | |
# Move the contents of the inner folder to the parent folder | |
mv "$fileName"/* "$newName"/ | |
# Remove the now-empty inner folder | |
rmdir "$fileName" | |
done | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment