• 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: Finding Filenames that contain a certain string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding Filenames that contain a certain string


  • Subject: Re: Finding Filenames that contain a certain string
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 21 Jul 2007 00:13:56 +0200

On 9/07/07 15:51, David Bradley wrote:

Hi,

I sent an e-mail to the list earlier entitled 'Finding Files containing a string'.

I've just realised that I meant to ask for help on search on filenames that contain a particular string.

For example, I would like to find all the files in a directory that have filenames that contain 'I325010' with either a, b, c, d, e, f, etc all the way to z, on the end.
I am searching thorough a directory of images and would like Applescript to pick out all the images that start with 'I325010' and then are followed by a letter.


Very sorry for the confusion, thanks for the all the help so far, I'm sure they'll come in use later.

Hello David,

Here follows an example of what could be done in "pure" AppleScript.
Sure not the most optimized code, but nevertheless able to handle folders with a reasonable count of files.


tell application "Finder"
set SourceFolder to folder "Volume:Path:To:Folder"
set FList to name of every file of SourceFolder
repeat with F in FList
-- Here, we assume "I325010" and "i325010" are both OK.
if F begins with "I325010" then
-- But here"a" and "A", for example, are not the same.
considering case
if last character of F is in "abcdefghijklmnopqrstuvwxyz" then
-- Do something with the file, here just fetch its size.
size of file F of SourceFolder
end if
end considering
end if
end repeat
end tell


Of course, the above could be written as a handler, say:

   on HandleFolder(path, startsWith, endsWith)

yet without the flexibility provided by all the other means already mentioned throughout the thread.
On the other hand, a few well thought handlers could cover all of your needs, without having to resort to tools other than the ones already provided by AppleScript.


HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Finding Filenames that contain a certain string (From: David Bradley <email@hidden>)

  • Prev by Date: Re: Finding Filenames that contain a certain string
  • Next by Date: Re: Finding Filenames that contain a certain string
  • Previous by thread: Re: Finding Filenames that contain a certain string
  • Next by thread: Re: Finding Filenames that contain a certain string
  • Index(es):
    • Date
    • Thread