Skip to content

Instantly share code, notes, and snippets.

@heralight
Last active December 26, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heralight/5e82f1917e5f70ace33cf5f7ee72cd80 to your computer and use it in GitHub Desktop.
Save heralight/5e82f1917e5f70ace33cf5f7ee72cd80 to your computer and use it in GitHub Desktop.
Automator Zip Compress / Uncompress with pattern filename
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
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
@heralight
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment