Skip to content

Instantly share code, notes, and snippets.

@markwk
Created April 5, 2019 04:30
Show Gist options
  • Save markwk/e1d69264a601034d27ec6b7bcd2d421a to your computer and use it in GitHub Desktop.
Save markwk/e1d69264a601034d27ec6b7bcd2d421a to your computer and use it in GitHub Desktop.
Mac Screenshot and Images Renamer: Run with the command line or via Alfred to give your images better titles.
#!/bin/bash
cd /Users/markkoester/Desktop/
clipboard=''
NL=$'\n'
for f in Screenshot*.png ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
# $(exiftool -d "%Y%m%d%H%M.%S" -CreateDate "$f" | awk '{print $4".png"}')"
clipboard="${clipboard}${NL}${filedatetime}.png"
fi
done
for f in Screen*.png ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
# $(exiftool -d "%Y%m%d%H%M.%S" -CreateDate "$f" | awk '{print $4".png"}')"
clipboard="${clipboard}${NL}${filedatetime}.png"
fi
done
for f in Screenshot*.jpg ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
clipboard="${clipboard}${NL}$filedatetime.jpg"
fi
done
for f in IMG_*.jpg ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
clipboard="${clipboard}${NL}$filedatetime.png"
fi
done
for f in IMG_*.JPG ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
clipboard="${clipboard}${NL}$filedatetime.png"
fi
done
for f in IMG_*.PNG ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
clipboard="${clipboard}${NL}$filedatetime.png"
fi
done
echo "$clipboard" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment