Last active
March 2, 2022 06:51
-
-
Save giuliobosco/908530e37e27cb56fd91a6e183c1812e to your computer and use it in GitHub Desktop.
macOS rename photos in folder for with photo shooting date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for filename in $(pwd)/*; do | |
line=$(mdls $filename | grep kMDItemFSCreationDate) | |
fileExtension=$(echo $filename | cut -f2 -d".") | |
datetime=$(echo $line | cut -f2 -d "=") | |
date=$(echo $datetime | cut -f1 -d " ") | |
time=$(echo $datetime | cut -f2 -d " ") | |
time=$(echo $time| sed -r 's/[:]+//g') | |
mv $filename $date-$time.$fileExtension | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment