Last active
December 26, 2017 13:56
-
-
Save heralight/5e82f1917e5f70ace33cf5f7ee72cd80 to your computer and use it in GitHub Desktop.
Automator Zip Compress / Uncompress with pattern filename
This file contains 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
for f | |
do | |
echo "$f" | |
dest="${f}.ext" | |
cmd="/Applications/Keka.app/Contents/Resources/keka7z -y -o\"${dest}\" x \"${f}\"" | |
echo $cmd | |
eval $cmd | |
done |
This file contains 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
tabargs=( "$@" ) | |
firstFile="$1" | |
directory=$(dirname "$1") | |
cd "$directory" | |
zipFileName=`basename "$firstFile"` | |
DATE=`date '+%Y%m%d_%H%M%S'` | |
zipFileName=${DATE}_${zipFileName}.zip | |
echo $zipFileName | |
echo $directory | |
what="" | |
function relpath() { | |
python -c "import os,sys;print(os.path.relpath(*(sys.argv[1:])))" "$@"; | |
} | |
for word in "${tabargs[@]}"; do what="${what} \"$(relpath "${word}")\""; done | |
action="zip \"${zipFileName}\" \ | |
$what \ | |
-x */.DS_Store \ | |
-x */.git \ | |
-x */.svn \ | |
-x */.idea \ | |
-X */__MACOSX" | |
echo $action | |
eval $action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be easily use with Automator with shell /bin/bash
Keka extract to folder.ext.sh
Keka Uncompress multiple compressed files to a sub directory with zipFilename.ext name under zipfilename directory.
Need Keka 1.1
Compress Selected file
to a zip file with name yyyymmdd_FirstFile.zip pattern.
e.g.:
aa.txt
bb.txt
will produce a 20171226_aa.zip with aa.txt and bb.txt