Skip to content

Instantly share code, notes, and snippets.

@oelna
Last active Jul 29, 2016
Embed
What would you like to do?
An Automator service that creates a .tar from files and folders selected in the Finder
#thanks to Gordon Davisson on SO: http://stackoverflow.com/a/35146562/3625228
files=()
for f in "$@"
do
path=`dirname "$f"`
file=`basename "$f"`
files+=(-C "$path" "$file")
done
tar -cf ~/Desktop/archive.tar "${files[@]}"
@p84mustang

This comment has been minimized.

Copy link

@p84mustang p84mustang commented Jul 29, 2016

For some reason, the .tar's created are double the size of the originating folder. Any ideas on how to resolve this? I tried taking the loop out and just tar'ing individual folders, but it still double in size with tar'd. Un-tar'd it goes back to same size. Same result on folders with very few large files. 7 GB turned into 14GB.

tar files doubled

files=()
path=''

for f in "$@"
do
path=dirname "$f"
file=basename "$f"

files+=(-C "$path" "$file")

done

tar -vc --exclude '02_Footage' -f ~/Desktop/"$file"_CON.tar "${files[@]}"

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