Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ( 08/02/12 05:06 AM ) - perhaps a better method described here:
- # http://stackoverflow.com/questions/11774560/batch-rename-screen-shots-on-mac-os-x
- # Rename Mac OS X Screen Shots by finding the pattern and replacing it to a
- # shorter string length.
- # Change into the Destop directory which is where screenshots are usually taken
- cd /Users/$USER/Desktop
- # do the renaming bits
- for i in *; do
- pattern="Screen\ Shot\ 20([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})\ at\ ([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{1,2})\ ([APM]{2})\.png";
- replacement="ss.\2-\3-\1 \4.\5.\6.\7.\png";
- new_filename=`/bin/echo $i | /usr/bin/sed -E "s/$pattern/$replacement/"`;
- if [[ "$new_filename" != "$i" ]]
- then
- /bin/mv "$i" "$new_filename";
- /bin/echo "new_filename: $new_filename";
- /bin/echo "old_filename: $i";
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement