• 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
Filename search & replace question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Filename search & replace question


  • Subject: Filename search & replace question
  • From: Ethan Rips <email@hidden>
  • Date: Tue, 22 Oct 2002 21:17:27 -0400

Hello, all

I. Background:

I need to write a script that accesses a bunch of files in a folder
whose names are something like this: {"385SOI1.txt", "385SOI2.txt",
"385SOA.txt", "385SOCR.txt", "385SOAL.txt", "385SOO.txt", "385SOC1.txt",
"385SOC2.txt", "385CFIA.txt", "385CFIB.txt", "385CFIC.txt",
"385CFIR.txt", "385CFIT.txt"}. (In reality, some of these have the code
appearing after the alpha part of the names; some also have spaces
between the alpha & the numerical portion of the file name.)

Adding to the fun, each document to which such a list of files
corresponds does not necessarily include the same combination of files.
Some have the SOA & SOCR files, for example, while others do not. There
are maybe 8 or 10 different types of files that could potentially be
included in a given document; most have 5 or 6.

I need to figure out how to do a search of the file names, appending a
numerical prefix ("01", "02", etc.) to each based on the alpha portion
of each filename (the existing alpha & numerical indexesfile1, file2,
etcwill take care of themselves in terms of the order in which the
renamed files appear in a listI assume, at least), and the presence or
absence of some of the other files (as noted in the paragraph above).
The result should be a list of files ordered by type as well as quantity
per type (i.e., SOI files in order followed by SOA & SOCR, then SOAL, or
followed directly by SOAL, etc.).

(A Better Finder Renamer does this well for files that are to be renamed
according to a single criterion, but obviously, it can't make decisions.
I need to do this programmatically.)

Once I've got that I can access each file in order for insertion in a
BBEdit document for massaging by an existing script.

II. The question (bet you thought I'd never get around to it):

Has anyone got any ideas on the most efficient way to do the search &
replace functions in the filenames prior to accessing the contents of
each file for insertion into a BBEdit file? Is there a better way to
approach this entire task?

Thanks.

Ethan
_______________________________________________
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.

  • Prev by Date: using apple script
  • Next by Date: Re: URL Access Scripting and WebStar
  • Previous by thread: Re: using apple script
  • Next by thread: My apologies for the double posting
  • Index(es):
    • Date
    • Thread