• 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: Simple Syntax Question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Syntax Question...


  • Subject: Re: Simple Syntax Question...
  • From: Ed Stockly <email@hidden>
  • Date: Sun, 3 Aug 2008 20:11:27 -0700


...but not for me, apparently. I am trying to check a known, specific directory for folders that contain only one directory. When those directories are found they are to be labeled "RED" so that they can subsequently be manually checked and deleted.

You're on the right track.

Here's how I would handle this:

tell application "Finder"
set checkFolder to folder "MBPro:Users:donmini:Desktop:Test Directory:"
repeat with a from 1 to (count of items of checkFolder)
if (count of items of (item a of checkFolder)) = 1 then
set label index of item a of checkFolder to 2
end if
end repeat
end tell


I avoid this method of file reference:

folder "Test Directory" of folder "Desktop" of folder "donmini" of folder "Users" of disk "MBPro"

I find this much easier to work with:
   folder "MBPro:Users:donmini:Desktop:Test Directory"

To get the finder to return the simpler file reference coerce it to text:

testFolder as text

Also, simply asking appleScript for the count of the folder won't work.

In my version those commands are included in the Finder tell and the Finder gets a list of items in the folder and appleScript counts the items in the list. (I added some optional parens () in the script to better illustrate what's happening)

It should be simple but I obviously have my syntax all fouled up. Can someone provide some insight into what I'm missing or doing wrong?


Once you get the hang of it, it is pretty simple, but even AppleScript has a learning curve!

HTH,

ES
_______________________________________________
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: Simple Syntax Question...
      • From: Don Fuller <email@hidden>
References: 
 >Simple Syntax Question... (From: Don Fuller <email@hidden>)

  • Prev by Date: Simple Syntax Question...
  • Next by Date: Re: Simple Syntax Question...
  • Previous by thread: Simple Syntax Question...
  • Next by thread: Re: Simple Syntax Question...
  • Index(es):
    • Date
    • Thread