• 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 (was: writing multiple files)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incrementing digits in a file name (was: writing multiple files)


  • Subject: Re: Incrementing digits in a file name (was: writing multiple files)
  • From: Jolly Roger <email@hidden>
  • Date: Thu, 19 Jul 2001 10:27:28 -0500

On 7/19/2001 3:14 AM, "monk" <email@hidden> wrote:

> 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

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

HTH

JR


  • Follow-Ups:
    • Re: Incrementing digits in a file name (was: writing multiple files)
      • From: monk <email@hidden>
References: 
 >writing multiple files (From: monk <email@hidden>)

  • Prev by Date: Re: FileMaker question
  • Next by Date: Facespan graphics
  • Previous by thread: writing multiple files
  • Next by thread: Re: Incrementing digits in a file name (was: writing multiple files)
  • Index(es):
    • Date
    • Thread