RE: Renaming Picture 1
RE: Renaming Picture 1
- Subject: RE: Renaming Picture 1
- From: "Wadson, David" <email@hidden>
- Date: Tue, 22 Jan 2002 09:46:43 -0500
I believe he's picked up the format_date_using handler from the Applescript
Guidebook help file for the Current Date OSAX. His syntax should work fine
as long as the handler is also in the script. It's a long, convoluted piece
of code:
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
>
> I want to rename a file and add the date, in YY-MM-DD format. The
>
filename
>
> gets altered correctly but the date isn't added!
>
>
>
> Here's what I wrote:-
>
>
>
> tell application "Finder"
>
> set the date_slug to my format_date_using(the current date, ".",
>
{"YY",
>
> "MM", "DD"})
>
> set filename to filename & " " & date_slug
>
> end tell
>
>
Unless you post the handler ("on format_date_using...end
>
format_date_using") you're calling in the above code there's no way that
>
anyone can help you with your problem.
>
>
Marc K. Myers <email@hidden>
>
http://AppleScriptsToGo.com
>
4020 W.220th St.
>
Fairview Park, OH 44126
>
(440) 331-1074
>
>
[1/22/02 12:21:08 AM]
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.