• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Incrementing digits in a file name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incrementing digits in a file name


  • Subject: Re: Incrementing digits in a file name
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sun, 22 Jul 2001 23:26:01 -0400
  • Organization: [very little]

> Date: Sun, 22 Jul 2001 05:58:12 -0400
> Subject: Re: Incrementing digits in a file name (was: writing multiple
> files)
> From: monk <email@hidden>
> To: "applescript users (apple)" <email@hidden>
>
> -- 7/19/01 11:27 am: email@hidden said:
>
> > How about something like this?:
> >
> > -- 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
>
> whenever i get to 'on', i get an error, ' expected "else", etc., but found
> "on".'
>
> what am i missing?

Your script ran without problems on my machine (AS 1.6, Mac OS 9.1)

If all you need to do is generate names with a sequence number, the
script can be greatly simplified:

set myPath to (path to desktop) as text
set rootName to "myfile "
repeat with i from 1 to 999
set myFilename to rootName & characters -3 thru -1 of ("00" & (i as text))
log myPath & myFilename
end repeat

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[7/22/01 11:24:45 PM]


  • Prev by Date: Disconnecting apple share users
  • Next by Date: Re: Disconnecting apple share users
  • Previous by thread: Re: Disconnecting apple share users
  • Next by thread: Newbie Quark Question Cont...
  • Index(es):
    • Date
    • Thread