Re: writing multiple files
Re: writing multiple files
- Subject: Re: writing multiple files
- From: "Marc K. Myers" <email@hidden>
- Date: Thu, 19 Jul 2001 13:07:46 -0400
- Organization: [very little]
>
Date: Thu, 19 Jul 2001 04:14:41 -0400
>
Subject: writing multiple files
>
From: monk <email@hidden>
>
To: "applescript users (apple)" <email@hidden>
>
>
question?
>
>
if i want to write files with an ascending digits, for example
>
>
--
>
if _filename = (((path to desktop) as string) & "myfile 00") then set
>
_filename open for access file (((path to desktop) as string) & "myfile 01")
>
with write permission
>
--
>
>
and so on up to 99
>
>
thanks
This looks for a number in the last two bytes of a file name and if it
finds them returns a file name with that number incremented. Is that
what you're looking for?
set filePath to (choose file) as text
set {od, AppleScript's text item delimiters} to {AppleScript's text item
delimiters, {":"}}
set fileName to text item -1 of filePath
set AppleScript's text item delimiters to od
set numStrng to text -2 thru -1 of fileName
try
set fileNbr to (numStrng as integer)
if fileNbr > -1 and fileNbr < 99 then
set fileNbr to fileNbr + 1
set newName to (text 1 thru -3 of fileName) & [optn-L]
(text -2 thru -1 of ("0" & (fileNbr as string)))
display dialog "New file name is " & newName
else
display dialog "Number out of range"
end if
on error
display dialog "File name did not end with a number"
end try
Note: Where you see "[optn-L]", substitute the AppleScript continuation character.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[7/19/01 1:06:43 PM]