• 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: David Bradley <email@hidden>
  • Date: Thu, 12 Jul 2007 10:25:23 +0100

Hi

I've got 'set fileNameList to paragraphs of (do shell script "cd " & (quoted form of POSIX path of startFolder) & " && ls -1 l325010[a- z]")' working without the [a-z] and find files.

When I put '[a-z]' it doesn't not find any.

Just to clarify I want to search through a directory and find files that start with l325010a, l325010b, l325010c, l325010d, l325010e, etc all the way to z. Is there a bit more synatx I need. I've searched on the web, but got no clues.

Cheers for all your help so far, much appreciated.

David Bradley
Senior Web Programmer
Globe Media
Brookfields Way
Manvers
Wath-upon-Dearne
Rotherham
S63 5DL

Tel: 01709 768231
Fax: 01709 768011
email@hidden
www.globe-media.com


On 9 Jul 2007, at 15:18, Mark J. Reed wrote:

On 7/9/07, David Bradley <email@hidden> wrote:
I've just realised that I meant to ask for help on search on
filenames that contain a particular string.


Oh. Well that's a much simpler problem.

set startFolder to (choose folder with prompt "Select folder to search in")
set fileNameList to paragraphs of (do shell script "cd " & (quoted form of POSIX path of startFolder) & " && ls -1 l325010[a- z]")


(The ls call isn't really necessary; the shell does all the work of finding the filenames and just tells ls to list their names, but that gets the newline after each one so that "paragraphs of" will work.)

Now, in this case you have a simpler AppleScript-only option, assuming you don't have filenames that start with l325010 but have something other than a-z after them. I'm not at a Mac where I can test this, so the syntax might be off, but something like this should work:

set fileNameList to every file of startFolder whose name starts with "l325010"

Might have to do it in a Finder tell block.


-- Mark J. Reed < email@hidden>

_______________________________________________ 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
  • Follow-Ups:
    • Re: Finding Filenames that contain a certain string
      • From: David Bradley <email@hidden>
References: 
 >Finding Filenames that contain a certain string (From: David Bradley <email@hidden>)
 >Re: Finding Filenames that contain a certain string (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: InDesign CS2: Problem with launching scripts out of the script window
  • 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