Created
July 4, 2020 04:16
-
-
Save gfxhacks/cf22de9b016bb4c23a117611fef9255a to your computer and use it in GitHub Desktop.
Rename files by creation date in OSX. More info: https://gfxhacks.com/renaming-files-by-date-from-metadata
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
#-- Make sure to specify your own filename.ext and all .ext instances. | |
#-- To overwrite the file, swap cp with mv. | |
# copy and rename file | |
cp filename.ext "newFileName-$(mdls -name kMDItemContentCreationDate filename.ext | sed 's/[^0-9]//g' | cut -c 3-14).ext" | |
# copy and rename all files in folder with specified extension. | |
for i in folder/*.ext; do cp "$i" "SomeTextHere-$(mdls -name kMDItemContentCreationDate "$i" | sed -e 's/[^0-9]//g' | cut -c 3-8)-someMoreTextHere.ext"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment