Rename a file using its created, modified, or added date, as read from its metadata.
More Info: https://gfxhacks.com/renaming-files-by-date-from-metadata
sh metadater.sh file.extalternatively, make the file executable:
chmod +x metadater.shThen copy/move it to the /usr/local/bin directory:
sudo mv metadater.sh /usr/local/bin/metadaterIf using a custom directory, make sure it's indexed in the PATH -
add this line to the .bashrc config file located in the Home directory (~), if using Bash; or .zshrc if using zsh:
If the config file doesn't exist, create it first.
export PATH=$PATH:/custom/dirNow the script can simply be run using:
metadater file.extEasily customize the script by adding/removing other metadata options. To list a file's metadata use:
mdls file.extHere are some kMDItem Date metadata options:
- kMDItemContentCreationDate
- kMDItemContentModificationDate
- kMDItemAttributeChangeDate
- kMDItemLastUsedDate
- kMDItemDateAdded
- kMDItemRecordingDate
- kMDItemFSContentChangeDate
- kMDItemFSCreationDate