Subscribe to
Posts
Comments
NSLog(); Header Image

Copy Mod Date to Created Date

I recently had an application wipe the creation date from about 2000 files, but leave the modification date intact. I was able to create a quickie AppleScript that relies on SetFile and GetFileInfo, a pair of CLI tools installed with the Developer Tools.

It's mostly here for my own use later on. I find myself re-learning when to get files as files, when to get them as aliases, when to access them via the paths, etc. just about every time I launch AppleScript.

tell application "Finder"
  set theFiles to the selection
end tell
repeat with theFile in theFiles
  set theFile to POSIX path of (theFile as alias)
  set copyDate to do shell script "/usr/bin/GetFileInfo -m '" & (theFile as string) & "'"
  do shell script "/usr/bin/SetFile -d '" & copyDate & "' '" & (theFile as string) & "'"
end repeat

Comments RSS

Leave a Reply


Warning: Undefined variable $user_ID in /var/www/vhosts/nslog.com/httpsdocs/wp-content/themes/nslog/comments.php on line 96

Please abide by the comment policy. Valid HTML includes: <blockquote><p>, <em>, <strong>, <ul>, <ol>, and <a href>. Please use the "Quote Me" functionality to quote comments.