Skip to content

Instantly share code, notes, and snippets.

@ncaq
Created April 10, 2013 09:40
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 ncaq/5353230 to your computer and use it in GitHub Desktop.
Save ncaq/5353230 to your computer and use it in GitHub Desktop.
Dropbox形式の写真ファイルネームからCopy形式に
#!/bin/zsh
#photo_list=(`ls -d -b --color=never *.jpg`)
for old_photo in *.(jpg|png|mp4)
do
new_photo=`echo ${old_photo} | perl -pe "s/[-_.]//g"`
new_photo=`echo ${new_photo} | perl -pe "s/[ ]/_/g"`
new_photo=`echo ${new_photo} | perl -pe "s/^/IMG_/g"`
new_photo=`echo ${new_photo} | perl -pe "s/jpg/.jpg/g"`
new_photo=`echo ${new_photo} | perl -pe "s/png/.png/g"`
new_photo=`echo ${new_photo} | perl -pe "s/mp4/.mp4/g"`
mv ${old_photo} ${new_photo}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment