Skip to content

Instantly share code, notes, and snippets.

@pavgup
Created May 4, 2015 15:02
Show Gist options
  • Save pavgup/0bbf8a84334736512b1e to your computer and use it in GitHub Desktop.
Save pavgup/0bbf8a84334736512b1e to your computer and use it in GitHub Desktop.
Find all images in a directory, create a backup subdirectory in the current directory, and then copy these images to the backup folder. Preparation for keeping track (poorly) of original files that are being optimized.
#!/bin/sh
mkdir backup; \
for file in $(
find . -exec \
file {} \; | \
awk -F':' '{ if ($2 ~/[Ii]mage|EPS/) print $1,"\n"}'| \
sed s/\.//);
do
cp -R -v .$file ./backup/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment