I have a folder of videos (Mac OSX Yosemite) for which I need to change the Created Date by adding 2180 days to the existing Created Date.
Using SetFile from Terminal I am able to manipulate the Created Date, for example I can set it as equivalent to the Modified Date of the same file:
SetFile -d "$(GetFileInfo -m /Users/myfilename.mov)" /Users/myfilename.mov
However, if I try to add the ‘Add 2180 days’ part it stops working:
SetFile -d "$(GetFileInfo -d /Users/myfilename.mov) +2180 days" /Users/myfilename.mov
I suspect it is an issue with bracket and speech marks but the following did not work either:
SetFile -d "$(GetFileInfo -d /Users/myfilename.mov +2180 days)" /Users/myfilename.mov
How exactly should I be incorporating the '+2180 days' into it?
Edi: Mark Setchell has a solution which works but I am keen to know if there is in fact a way to incorporate '+2180 days' into the GetFileInfo-based -d date variable.
man SetFile
for the format−d date
is expecting.SetFile
is quite explicit as to what format−d date
requires and why I suggested you readman SetFile
to begin with. Note that the output ofGetFileInfo -d file
is within the constraints of expected format thatSetFile −d date
requires. Therefore one must do in a similar way what Mark Setchell presented in order to do the math as neither utility has the ability to parse directly the math in the manner you've expressed in the OP.SetFile -d date
must conform to this format,"mm/dd/[yy]yy [hh:mm:[:ss] [AM | PM]]"
, e.g.02/09/2015 01:11:50
. The output ofGetFileInfo -d
or-m
is in this format,mm/dd/yyyy hh:mm::ss
, e.g.02/09/2015 01:11:50
. You cannot directly addmm/dd/yyyy hh:mm::ss + n days
, e.g.02/09/2015 01:11:50 + 2180 days
and the values must be converted in order to do the math! Mark Setchell has shown you one of the ways to do the math. Do you get now? :)