Created
June 11, 2016 15:36
-
-
Save nknote/b160adf819078a5d90a682f5f2eaf59e to your computer and use it in GitHub Desktop.
Find all zip files in current folder and subfolders and extract the contents in a folder with the zip file name.
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 | |
rootdir="$PWD" | |
find "$rootdir" -type f -name '*.zip' | while read file;do # find all .zip files in the directory | |
cd "$(dirname "$file")" | |
if [ "$(dirname "$file")" = "$PWD" ];then # if the file found is in the same directory as defined "rootdir" | |
mkdir "$(basename "$file" | cut -d. -f1)" | |
cd "$(basename "$file" | cut -d. -f1)" | |
unzip -O cp949 -n "$file" # unzip the file | |
mv "$file" "$file".tododelete | |
else | |
echo "error" | |
break | |
fi | |
done | |
cd "$rootdir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment