Re: Incrementing digits in a file name (was: writing multiple files)
Re: Incrementing digits in a file name (was: writing multiple files)
- Subject: Re: Incrementing digits in a file name (was: writing multiple files)
- From: JollyRoger <email@hidden>
- Date: Sun, 22 Jul 2001 12:28:40 -0500
On 7/22/2001 11:56 AM, "monk" <email@hidden> wrote:
>
-- 7/22/01 05:58 am: email@hidden said:
>
>
> -- 7/19/01 11:27 am: email@hidden said:
>
>
>
>> How about something like this?:
(snip)
>
> whenever i get to 'on', i get an error, ' expected "else", etc., but found
>
> "on".'
>
>
>
> what am i missing?
>
>
i think this one was my bad syntax, i had an unended if in the larger
>
framework, sorry!
>
>
but, now i get an error 'expected error but found identifier.'
If you are retyping the script, then you are probably introducing typos into
the script. Instead of typing it by hand, try copying the code directly
from your emailer and pasting it into Script Editor. The script should run
as I originally posted it without modification. Here it is again for your
convenience:
-- begin script
set myPath to (path to desktop) as text
set myFilename to "myfile 00"
repeat with i from 1 to 99
set myFilename to my IncrementFilename(myFilename)
log myPath & myFilename
end repeat
on IncrementFilename(oldName)
set digits to (characters -1 thru -2 of oldName) as text
set digits to digits + 1
set newName to (characters 1 thru -3 of oldName) as text
if digits < 10 then set newName to newName & "0"
return newName & (digits as text)
end IncrementFilename
-- end script
If, on the other hand, the error you are getting is the result of other code
you have added to the script, then I will have to see all of the code to be
able to diagnose the problem.
JR