• 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: AS how to check if a file name matches a string in a text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS how to check if a file name matches a string in a text file


  • Subject: Re: AS how to check if a file name matches a string in a text file
  • From: "koenig.yvan" <email@hidden>
  • Date: Sun, 29 Jun 2014 21:28:51 +0200


Le 29/06/2014 à 21:18, Jim Weisbin <email@hidden> a écrit :


On Jun 29, 2014, at 3:00 PM, koenig.yvan wrote:

You may use TextEdit to read the file's contents with this kind of code :

set theFilePath to (path to desktop as text) & "Sans titre.rtf"

tell application "TextEdit"
open file theFilePath
set theText to text of document 1
end tell
theText

But maybe there is a way to do the same using an Unix command.


Thanks, this helps a lot. 

I mentioned shell because sed would be the easiest way to find a text string, I think, but I’m sure it can be done in AS.


Here is a script supposed to achieve the entiere goal :

# I stored the text of your original message in "Sans titre.rtf"

set theFilePath to (path to desktop as text) & "Sans titre.rtf"

tell application "TextEdit"
open file theFilePath
set theText to text of document 1
end tell
set listOfFileNames to {"comfortable", "TextEdit", "Yvan KOENIG", "Weisbin"}
set foundNames to {}

repeat with aName in listOfFileNames
set aName to aName as text
if theText contains aName then set end of foundNames to aName
end repeat
foundNames
--> {"comfortable", "TextEdit", "Weisbin"}

Yvan KOENIG (VALLAURIS, France) dimanche 29 juin 2014 21:28:38




 _______________________________________________
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: AS how to check if a file name matches a string in a text file
      • From: Shane Stanley <email@hidden>
References: 
 >Re: AS how to check if a file name matches a string in a text file (From: Jim Weisbin <email@hidden>)

  • Prev by Date: Re: AS how to check if a file name matches a string in a text file
  • Next by Date: Re: AS how to check if a file name matches a string in a text file
  • Previous by thread: Re: AS how to check if a file name matches a string in a text file
  • Next by thread: Re: AS how to check if a file name matches a string in a text file
  • Index(es):
    • Date
    • Thread