Change a file date (creation and modification)
Change a file date (creation and modification)
- Subject: Change a file date (creation and modification)
- From: Emile Schwarz <email@hidden>
- Date: Sat, 12 Feb 2011 15:18:09 +0100
Hi all,
I have created a script to change the dates of a file (in fact I need to
change the dates on more than 1.000 files… so I started with one).
At first I used a folder (fast object to create) and nothing works…
Then, I've made a copy of a JPEG file (created in February 2011) inside
that folder and worked on it.
To my great surprise, I was able to change not only the modification
date but also the creation date.
Do not get me wrong: it is good to what I want to do *.
But, the Finder dictionary says for (item n : An item):
creation date (date, r/o) : the date on which the item was created
modification date (date) : the date on which the item was last modified
I nearly forgot: I run a MacBook (2008-11) with Mac OS X 10.6.6 (and a
lot of troubles, but this is a different story).
Your opinion ?
Emile
The used script:
tell application "Finder"
--
-- The target item have to be in the front window
-- no windoid not information window can be in front…
--
set TargetItem to item "Tarzan_19720402.jpg" of front window as alias
-- Get creation and modification dates of the item
-- set DateCreated to creation date of TargetItem
set DateModified to modification date of TargetItem
-- CREATION DATE IS R/O! So, I only change the modification date
set aYear to year of DateModified
-- Change the year of the target item if its year is 2011…
if aYear is 2011 then
-- Commented line:
-- error: unable to set the year of modification date of document file…
-- set year of modification date of TargetItem to 1954
-- But the two next lines works fine…
set year of DateModified to 1954
set modification date of TargetItem to DateModified
end if
end tell
* I downloaded nearly 1.500 files (comic strips) and I want to set each
file to its release date.
That date is inside its url; I placed the file url into the Comments
file; I have the 'image file name' and 'url' in a text file so it is
easy to create a text file with <character_date.gif> \tab
<creation_date> \return. I only have to loop thru the text file and
change the images files dates accordingly.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden