Skip to content

Instantly share code, notes, and snippets.

@jghorton14
Last active September 25, 2020 16:16
Show Gist options
  • Save jghorton14/1511e0ebeb792393557f017b9bcbc225 to your computer and use it in GitHub Desktop.
Save jghorton14/1511e0ebeb792393557f017b9bcbc225 to your computer and use it in GitHub Desktop.
Im terrible at bash... But a bash script that organizes your files by a date format to be easily sorted
#!/bin/bash
# Install exiftool to grab metadata from picture
sudo apt-get install libimage-exiftool-perl
# Create Directory to format
mkdir Formatted
# jpg
for f in *.jpg
do
DATE=$(exiftool -T -createdate -d "%Y-%m-%d(%I:%M%p)" $f)
cp $f Formatted/
cd Formatted/
mv $f $DATE.jpg
cd ..
done
# JGP
for f in *.JPG
do
DATE=$(exiftool -T -createdate -d "%Y-%m-%d(%I:%M%p)" $f)
cp $f Formatted/
cd Formatted/
mv $f $DATE.JPG
cd ..
done
# png
for f in *.png
do
DATE=$(exiftool -T -createdate -d "%Y-%m-%d(%I:%M%p)" $f)
cp $f Formatted/
cd Formatted/
mv $f $DATE.png
cd ..
done
# PNG
for f in *.PNG
do
DATE=$(exiftool -T -createdate -d "%Y-%m-%d(%I:%M%p)" $f)
cp $f Formatted/
cd Formatted/
mv $f $DATE.PNG
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment