• 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: Nick Hearn <email@hidden>
  • Date: Mon, 9 Jul 2007 16:23:58 +0100

***Before acting on this email or opening any attachment you are advised to read the disclaimer at the end of this email***
************************************

Hi Dave,

This creates the list and copies it to the clipboard. The list can then be pasted into a text editor.

Regards,

Nick


display dialog "Enter the search string" default answer "" buttons {"Cancel", "OK"} default button {"OK"}
set theSearchString to text returned of result

if theSearchString = "" then
display dialog "No search criteria entered!" with icon caution
return
end if

tell application "Finder" to set theFileList to (files of entire contents of (choose folder) whose name contains theSearchString) as alias list

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set the clipboard to theFileList as text
set AppleScript's text item delimiters to oldDelims

display dialog "The file List has been copied to Clipboard." & return & return & "Simply paste it into a text editor."




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>








**********************************************************************
Communisis plc - registered no: 2916113 is a limited company registered in England and Wales and whose registered office is at Wakefield Road, Leeds, LS10 1DU.

Please Note: This e mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy (s) of the Communisis group in general.

Confidentiality: This e-mail and the contents of any attachments are intended for the named recipient(s) only and may be confidential. If you have received this e-mail and its contents in error you must take no action based on them, nor must you copy or show them to anyone. Please reply to this e-mail and highlight the error.

Warning: Although this e-mail and any attachments have been scanned for viruses, Communisis cannot guarantee that they are virus free. The Communisis group therefore accepts no responsibility for any loss or damage caused by transmission of this e-mail.
**********************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
 _______________________________________________
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: Luther Fuller <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: Finding Filenames that contain a certain string
  • Next by Date: Re: Help about Word
  • 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