Re: Testing for a specific value in a folder name
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