Re: Elementary fie naming question
Re: Elementary fie naming question
- Subject: Re: Elementary fie naming question
- From: Graff <email@hidden>
- Date: Tue, 16 Dec 2003 18:02:22 -0500
The problem is the underlying Unix-like nature of Mac OS X. You can't
have a file name that has a slash (/) in it because that character is
used for separating directories. In the Finder all slashes (/) are
automatically translated to dashes (-). Tex Edit+ just hands back an
error to AppleScript instead of renaming the file for you. So all you
need to do is to replace the slashes with dashes in your
name-generating code. Here's an example script that works (and doesn't
use a shell command to get the date):
----------
set theDate to the current date
set theDay to the day of theDate as integer
set theMonth to the month of theDate as integer
set theYear to the text 3 thru 4 of (the year of theDate as text)
set theName to "OCR " & theDay & "-" & theMonth & "-" & theYear & ".txt"
set thePath to (the path to the desktop folder as text) & theName
tell application "Tex-Edit Plus"
-- insert your code here
save window 1 in thePath
end tell
----------
- Ken
On Dec 16, 2003, at 2:50 PM, Bernard Azancot wrote:
Hello scripters !
My problem is simple.
I would like to save a Tex Edit + file with a name containing the date.
I must have missed an AS book chapter... ;-)
=-=-
tell application "Tex-Edit Plus"
tell window 1
--replace blah blah...
--replace blah blah...
--replace blah blah...
set timestring to do shell script "date '+%d/%m/%Y'"
set TheNewName to "OCR " & timestring & " .txt"
--> File name example: "OCR. 16/12/03.txt"
save window 1 in file "IBM 01:Users:parents:Desktop:" & TheNewName &
" .txt" as string with creator +class TBB6;
end tell
end tell
=-=-
_______________________________________________
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.