Re: Renaming Picture 1
Re: Renaming Picture 1
- Subject: Re: Renaming Picture 1
- From: Graham Fielder <email@hidden>
- Date: Wed, 23 Jan 2002 10:05:01 -0500
Finally solved my problem - thanks to all who helped.
Graham.
Some of the code may be redundant but here's the script I used, for those
who are interested.
tell application "Finder"
display dialog "Which Snapshot do you want to re-name & add date to?"
buttons ,
{"TelPay", "VISA", "LOC"} default button 3
copy the result as list to {the snapshot}
activate
select startup disk
open selection
select file "Picture 1" of startup disk
set name of selection to the snapshot
move file snapshot of startup disk to folder snapshot of folder ,
"Snapshots" of folder "Utilities" of folder ,
"Applications" of startup disk
set the date_slug to my format_date_using(the current date, ".", ,
{"YY", "MM", "DD"})
select file snapshot of folder snapshot of folder ,
"Snapshots" of folder "Utilities" of folder ,
"Applications" of startup disk
set name of selection to snapshot & " " & date_slug
--set newName to the date_slug --> create string
end tell
--This is the handler using sub-routine format_date_using taken from
Applescript GuideBook
on format_date_using(this_date_record, delimiter_string, format_list)
-- get the numeric day
set numeric_day to the day of this_date_record
-- get the month
set month_name to the month of this_date_record
-- convert month to number
set the list_of_months to {January, February, March, April ,
, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item i of the list_of_months is the month_name then
set the numeric_month to i
exit repeat
end if
end repeat
-- get the numeric year as text
set numeric_year to the year of this_date_record as string
set the formatted_date to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "D" then
set the formatted_date to ,
the formatted_date & numeric_day as string
else if this_item is "DD" then
if the numeric_day is less than 10 then ,
set numeric_day to ,
("0" & (the numeric_day as string))
set the formatted_date to ,
the formatted_date & numeric_day as string
else if this_item is "M" then
set the formatted_date to ,
the formatted_date & numeric_month as string
else if this_item is "MM" then
if the numeric_month is less than 10 then ,
set numeric_month to ,
("0" & (the numeric_month as string))
set the formatted_date to ,
the formatted_date & numeric_month as string
else if this_item is "YY" then
set the formatted_date to ,
the formatted_date & ,
((characters 3 thru 4 of numeric_year) as string)
else if this_item is "YYYY" then
set the formatted_date to ,
the formatted_date & numeric_year
end if
if i is not the item_count then
-- add delimiter
set the formatted_date to ,
the formatted_date & delimiter_string as string
end if
end repeat
return the formatted_date
end format_date_using