I have files named "clip-2016-03-01 10;01;14.mp4" and would like to make filename to creation date of file.
Found this thread
read creation date from file name and change – batch
for f in *; do
t=$(echo $f | sed -E 's/([A-z]*-)|([ ,;])|(\..*)//g' | sed -E 's/(.*)(..)/\1.\2/')
touch -t $t "$f"
done
But I'm not that used to using terminal.
1. Where do I put the search string to the folder containing the files in terminal?
- Also found another thread suggesting that touch command won't work and that I should use SetFile -d command.
https://superuser.com/questions/492342/how-can-i-batch-shift-the-creation-date-of-files-on-os-x-10-6-8
Best Answer
This will operate on all files in the
Current Directory
. You couldcd ~/MyDirectory
, either in the script or inTerminal
before running it. Another option is to change the*
infor f in *; do
to~/MyDirectory/*
This won't actually give you the creation time, because it isn't stored by Unix.
Ctime
actually records the time of the last status change (which may or may not be creation time).OS X
seems to store other data in extended attributes, but this is not what the script does.