• 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: Testing for a specific value in a folder name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing for a specific value in a folder name


  • Subject: Re: Testing for a specific value in a folder name
  • From: Malcolm Fitzgerald <email@hidden>
  • Date: Wed, 5 Jul 2006 13:19:02 +1000


On 05/07/2006, at 11:13 AM, Brett Conlon wrote:

I have a word list  (taked from a folder name) and I want to test for a spoecific word in it.
...

Here's what I have so far but the last line errors....

on run
        set aFolder to choose folder
        CheckDNum(aFolder)
end run

on CheckDNum(aFolder)
        tell application "Finder"
                set item_name to the name of aFolder as text
                set AppleScript's text item delimiters to " "
                set AllWords to every word of item_name as list
                log AllWords
                set Dnum to every word of AllWords whose character 1 is "D"
        end tell
end CheckDNum


The last line errors because you asked a list for it's words. Strings have words, lists have items. Try this:

on run
	tell application "Finder" to set aFolder to name of (choose folder)
	CheckDNum(aFolder)
end run


on CheckDNum(aFolder) set Dnum to {} repeat with chunk in (every word of aFolder) considering case -- we are looking for capitals if item 1 of chunk is "D" then if length of chunk is in {5, 6} then -- is it the right length? try (text 2 thru -1 of chunk) * 1 -- is the remainder a number? set end of Dnum to chunk as Unicode text end try end if end if end considering end repeat return Dnum end CheckDNum



Malcolm Fitzgerald


FOR YOUR COMPUTER Customised software built to your specifications. Using Macs? Automate your workflow with AppleScript. FOR YOU Computer training, software installation + upgrades, computer setups. IN TIMES OF NEED Troubleshooting, maintenance + repairs.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Testing for a specific value in a folder name
      • From: Malcolm Fitzgerald <email@hidden>
References: 
 >Testing for a specific value in a folder name (From: Brett Conlon <email@hidden>)

  • Prev by Date: Popup menu in interface builder
  • Next by Date: Re: Testing for a specific value in a folder name
  • Previous by thread: Testing for a specific value in a folder name
  • Next by thread: Re: Testing for a specific value in a folder name
  • Index(es):
    • Date
    • Thread