r/applescript • u/Internautic • Sep 04 '22
Adjust dates of items inside folders
/r/MacOS/comments/x5z86k/need_tips_on_a_script/
2
Upvotes
r/applescript • u/Internautic • Sep 04 '22
1
u/copperdomebodha Sep 05 '22
Creation dates or modification dates?
1
u/estockly Sep 05 '22 edited Sep 05 '22
Try something like this. The script assumes that the first word of each folder is the four digit year. If that's not the case, then as someone else suggested, let us know what the date format is.
This changes the
creationmodification date.ModificationCreation dates are a little trickier, but that can also be done.use AppleScript version "2.4" -- Yosemite (10.10) or lateruse scripting additions--set rootFolder to (choose folder) as aliastell application "Finder" to set finderSelection to the selection as alias listrepeat with rootFolder in finderSelectionmy FixDates(rootFolder)end repeaton FixDates(aFolder)tell application "Finder"if kind of aFolder is "Folder" thenset everyFolder to every folder of aFolderelsereturnend ifend tellrepeat with thisFolder in everyFolderset thisFolder to thisFolder as textmy FixDates(thisFolder as alias)end repeattell application "System Events" to set folderName to the name of aFoldertryset theYear to word 1 of folderName as numberset theYear to theYear - 2on errorreturnend trytell application "System Events" to set allTheFiles to every file of aFolderrepeat with thisFile in allTheFilestell application "System Events"set fileModDate to the modification date of thisFileset year of fileModDate to theYearset the modification date of thisFile to fileModDateend tellend repeatend FixDates1
u/[deleted] Sep 08 '22
https://exiftool.org is your friend...oblig.a/s.content:
set out to do shell script "/usr/local/bin/exiftool"...
1
u/copperdomebodha Sep 09 '22