Applescript that searches for folders by name

I've set up a bunch of folder action scripts on our Xserve that changes the colour label of folders when they are dropped into specific folder, I use this to help organise which jobs are live and which are finished and ready for backup.
The system works well, but because there is a live work folder and finished work folder for each of our clients and each of these has a folder action attached, our server is taking quite a hammering with System events using huge processor cycles.
Someone kindly came up with the script below for a stay open script that would check the folders every 30 seconds and change the folder labels, which would be perfect, but it only finds "Live Work" and "Finished Work" folders on the desktop, All our Client folders are actually on a xserve RAID, so I need to modify the script so it seaches all of the RAID for folders called "live work" or "finished work" and batch changes the colour label.. any ideas?
property LiveWorkFolder : "Live Work"
property FinishedWorkFolder : "Finished Work"
property NoColor : 0
property Orange : 1
property Red : 2
property Yellow : 3
property Cyan : 4
property Magenta : 5
property Green : 6
property Gray : 7
on idle
tell application "Finder"
repeat with d in folder LiveWorkFolder
set label index of d to Green
end repeat
end tell
tell application "Finder"
repeat with d in folder FinishedWorkFolder
set label index of d to Red
end repeat
end tell
-- rerun this routine for constant surveillance
return -- rerun by default every 30 seconds
-- return 10 -- rerun every 10 seconds
end idle

01. In your original post, you stated:
property LiveWorkFolder : "Live Work"
property FinishedWorkFolder : "Finished Work"
...; however, in your pictorial reply post - you show 'Finished Jobs' and 'Live Jobs'.
Also, as such - i do not know how your code works; since the 'LiveWorkfolder' and 'FinishedWorkFolder' properties, or - else where in your code you, do not supply a complete file path.
02. Via 'Disk Utility' I created a disk image - titled 'RAID'. In 'RAID' I created three (3) folders {All-Clad, ASDA, and Bentley}, which each containing a 'Projects' folder; and each 'Projects' folder containing folders 'Finished Jobs' and 'Live Jobs'. In these last two (2) folders I place some randomly selected files.
The code below (based on my above posted code - which had 'on idle', 'return', and 'end idle' commented out) worked, as expected.
property LiveWorkFolder : "Live Jobs"
property FinishedWorkFolder : "Finished Jobs"
property MasterPath : "RAID" -- The name of the folder, or volume, which contains the folders of the users, whose related folders contain the 'Live Work' and 'Finished Work' folders.
property NoColor : 0
property Orange : 1
property Red : 2
property Yellow : 3
property Cyan : 4
property Magenta : 5
property Green : 6
property Gray : 7
on idle
tell application "Finder"
set liveWorkFolder_List to every folder of entire contents of folder MasterPath whose name contains LiveWorkFolder
set FinishedWorkFolder_List to every folder of entire contents of folder MasterPath whose name contains FinishedWorkFolder
repeat with i in liveWorkFolder_List
set label index of every item in i to Green
end repeat
repeat with i in FinishedWorkFolder_List
set label index of every item in i to Red
end repeat
end tell
-- rerun this routine for constant surveillance
return 30 -- rerun by default every 30 seconds
-- return 10 -- rerun every 10 seconds
end idle
03. At least here (in 'on idle' ... 'end idle' ) ...
return
... by itself, does not imply 'return 30'. Thus, the reason for ...
return 30
... above.
  Mac OS X (10.4.8)  

Similar Messages

  • How do I search for a specific name of an email sender?

    I'm trying to locate, in the easiest way possible, a name that should have appeared in my inbox... How do I search for a specific name?

    type it in the big box on the toolbar and press enter.

  • How can i search for multiple file names (images) in bridge?

    Hello everyone!
    Does anyone know how to search for multiple file names in bridge?
    That is to copy & paste something like this: _MG_2152, _MG_2177, _MG_2194, _MG_2195, _MG_2202, _MG_2212, _MG_2219, _MG_2261, _MG_2362, _MG_2401
    Not using several criterias in the search box that is. That takes too long.
    Thanks
    Steffen Rikenberg Photographer
    Oslo, Norway.
    www.steffenrikenberg.no

    Try this add-on [https://addons.mozilla.org/it/firefox/addon/find-all/ Find All]

  • Searching for a file name?

    Hey Guys,
    Is there a way to fine the name of a text file? For example, I have 3 files 1235.txt, 2568.txt, and 2568.txt. I need to find one of these files and write user info into each one and then update the file with current user info.
    I was just wonder if there is anyway you could search for a file name?
    The reason I need to do this is because I want to store user details into seperate files, because I don't really want to use a random access file and using one file for all the users seems alot harder, when finding a file users info...
    Thanks Guys,
    The 31st Cook
    PS. I will post the code if required.... Thanks Again

    O yeah, I remember (google refresh my memory) this is what we were going to use in the first place except.. Because we must demo the program on completely locked down computers we can't install the drivers (that's what I was told) So, we can't use it...

  • Trying to install Leopard on my iMac (G5).  Got to the screen that asks for the user name and password and it won't take it.  How do I get out of this and resume the software install?

    Trying to install Leopard on my iMac (G5).  Got to the screen that asks for the user name and password and it won't take it.  How do I get out of this and resume the software install?

    Help here >  Mac OS X: Changing or resetting an account password

  • I cannot remove "..." that appear for several account names . .

    I cannot remove the quotation marks that appear for several account names in the new message window; eg I want "J. Smith" to read J. Smith. Strange thing is that there are no quote marks in the account name field in preferences. I've tried deleting the name then re entering it. I've also made the prefernces the same as the other names that don't have quote marks but still no success. How do I get rid of these annoying marks? Any help would be great!
    MacBook   Mac OS X (10.4.9)  
    MacBook   Mac OS X (10.4.9)  

    The RFC 2822 - Internet Message Format standard requires names containing punctuation characters to be enclosed in double quotes. If Mail didn’t do that automatically for you, those messages would be malformed.

  • Applescript Help: Search for text in Safari DOM tree

    Im trying to make a script really similar what was asked here: Re: Find text in webpage and email notification applescript/automator Except instead of searching the "source code" of the page, I want the script to search the "DOM tree" for the page.
    To summarize, I am trying to make a script that loads a safari page, searches for a particular text in the DOM Tree, and if found will send me an email.
    Here is the code from the other thread I referenced:
    on idle
              set pagURL to "http://page.url.com?whatever"
              if application "Safari" is not running then
                        quit
                        return
              end if
              tell application "Safari"
                        set URL of document 1 of window 1 to "http://your.web.address/"
                        delay 5
      -- delay to let page load.
                        if source of document 1 of window 1 contains "search text" then
                                  my sendAMail()
                        end if
                        return 900 --fifteen minutes
              end tell
    end idle
    on sendAMail()
              tell application "Mail"
                        set theMess to make new outgoing message at end with properties {sender:"your name", subject:"some subject line", content:"The message you want to send to yourself", visible:true}
                        tell theMess
                                   make new to recipient at end of to recipients with properties {address:"[email protected]"}
                        end tell
      -- send theMess
              end tell
    end sendAMail
    Any help would be appreciated!

    For the URL you quote as an example (http://www.sislands.com/coin70/week2/NestedLoops1.htm), using text instead of source worked for me:
    if text of document 1 of window 1 contains "1  2  3  4" then
    another example:
    if text of document 1 of window 1 contains "10 12 14 16" then
    Note a double space between single digits (1  2  3  4) and a single space between double digits (10 12 14 16) is required for a match as per the table format:
    Any full line:
    if text of document 1 of window 1 contains "for (i = 1; i <= 10; i++) { // when i = 10" then
    or partial line works:
    if text of document 1 of window 1 contains "; i++) { // when i = 10" then

  • How do I use search/find to search for a folder name

    I can successfully use Spotlight and Search in Finder and Mail to find files and emails based on their titles and contents, but how to I use the search functions to find a FOLDER by its name, that I have somehere in my nests of folders - so I can then look inside that folder for what I am looking for.
    The search results never seem to show up any folder names?

    I do have several levels of nested email folders and several hundred folders created over the years. So I was hoping to be able to search for a folder's name, and be taken to it to see it and all of its contents.
    The best I seem to be able to do is search for a word that I hope I remember is in one of the emails in that folder, and then find that email in the search results list - but that list still doesn't tell me where the folder in the nested heirarchy that is my mailbox

  • Spotlight search for folders

    hello
    i was wondering if there is way, in the finder window, to search for a folder. i mean like if you want a pdf, you type the name, then .pdf ;specifically, I am looking for the Library folder to get at my .plist files. thanks, i hope that makes sense.

    From any active Finder window press COMMAND-F to bring up a Spotlight search query or simply enter a search string in the search field in the right side of the Finder's toolbar.
    Note that Spotlight will not search system folders unless you configure its search options.

  • Applescript that scans for labels?

    Does anyone know if applescript can scan for finder labels? I am wondering because I tried to have an automator workflow scan recursively (until I learned automator does not work recursively) for all the files in my home directory with the gray label "unimportant" and move them to a folder on the desktop for my review and then subsequent deletion.
    The only thing is that it obviously does not work, and I have no clue how to use Applescript. Any ideas?
    Thank You,
    Ga776m

    I have found (reproducibly) that if you set up a smart folder to search for a coloured label, and then change the label colour of any of the files returned by the search, the smart search will continue to return that file. For example, I run a smart search for files with a grey label, and then change one of the labels to red:
    The red file is still returned by the grey search.
    (Thinks - must file a bug report.)
    The same happens if you DO use an AppleScript:
    set found_files to paragraphs of (do shell script "mdfind " & quoted form of "kMDItemFSLabel = 1") --search for grey files
    tell application "Finder"
              try
                        set the_folder to (make new folder at desktop with properties {name:"For Review"}) --create the target folder if it doesn't already exist
              end try
    end tell
    repeat with each_file in found_files -- move all the files to the target folder
              set each_file to file each_file
              tell application "Finder"
      move each_file to the_folder without replacing
              end tell
    end repeat
    This moves the red file (originally labelled grey) to the "For Review" folder along with any grey ones. It doesn't have to be recursive because it used the power of mdfind.
    Like I say, it may not be an issue if the OP doesn't want to change the labels of the grey files.
    But I'd be interested to know if anyone else sees the same apparent misbehaviour.
    H

  • Searching for missing column names in a single database.

    I have a database with about 100 tables, database gets generated using entity framework. The application has been enhanced  so users deployed with older version of the application need to upgrade to newer version. The database generated is both versions
    is same name.
    Now, the older version is missing some tables and column names that are in new database.
    Is there a script that can search for missing fields in a single database as described in this situation?
    Below is my script. Basically, nameofdatabase would the database generated and that already existing. If you install the application and database already exits no new database will be created.
    SELECT * FROM (Select TABLE_CATALOG, Table_name,COLUMN_NAME FROM nameofdatabase.INFORMATION_SCHEMA.COLUMNS) a FULL OUTER JOIN (SELECT TABLE_CATALOG, Table_name,COLUMN_NAME FROM nameofdatabase.INFORMATION_SCHEMA.COLUMNS) b ON b.COLUMN_NAME=a.COLUMN_NAME and
    a.TABLE_NAME=b.TABLE_NAME WHERE b.COLUMN_NAME is null or a.COLUMN_NAME is null ;

    There is a great tool called SQLCompare provide by www.red-gate.com
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Search for a file name by time stamp

    Powershell allows us to append the date faily easily to a file name (eg. "test.txt $(get-date -f dd-MM-yyyy).txt").  I'm looking for a simple script to search for a powershell script by a static name with todays date appended.  I
    then want to move that file to a another location and rename it. For example lets say the file name is test.txt always and a 3rd party software names it to test12-9-14.txt daily so tommorow it would be test12-10-14.txt and so on.  Each day I need
    to take the file testxx-xx-xxxx.txt from the the c:\ drive and move it to the w:\ drive and change the name from testxx-xx-xxxx.txt to test.csv.

    I found the typo mm instead of MM which was my problem from the beginning.  MM represents month not mm.  A simple mistake that costed a lot of time.  Thanks Mike
    Cheers, you're very welcome. Glad I could help out.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Search for folders?

    I know how to search for jpegs or documents by a file name but what about a name of a folder? thanks in advance

    If you do a search in Spotlight it should find the names of folders as well as files. You don't mention what version of the operating system you have so I can't tell if you have Spotlight available. The icon would be in your menubar at the top right corner of your screen and it looks like a magnifying glass.
    Best of luck.

  • Searching for Folders

    Even though apps get catalogued in folders; I still have a doozy of a time finding the folder I want with 9 pages of stuff; it would be great if spotlight could search for a specific folder name; or is there already a way to do this in search....?

    These are user-to-user forums, you are not talking to Apple here and they do not monitor these forums. If you want to leave feedback for Apple then you can do so here : http://www.apple.com/feedback/ipad.html

  • How do I search for a PROJECT name?

    I go to Find>Other Data>Project>includes>{string}, but it doesn't find the string (which I know exists).
    I've tried this from Library, All Photos, and from Blue Folders that contain projects. Doesn't find anything.
    Any ideas would be appreciated. Thanks.

    I put in a feature request for a "spotlight" type feature in the Projects Inspector. Please do the same.
    If I remember which folder I put it in, I don't need to search for it.
    Also the method above just displays the images from that project. It doesn't tell me precisely where the project is located.
    DLS

Maybe you are looking for

  • I think I bought a fake or counterfeit version of Photoshop CS6 extended.  How do I find out for sure.

    i am using windows 7 on an HP Pavilion dv6-6108.   I purchased Photoshop CS6 extended.  The guy said it is a full Retail version and "self installs" the serial number and activates.  It doesn't fully install into my control panel programs, instead it

  • LOVs in Discoverer

    I have a table that stores Cost Center and Description. I want to show an LOV like 100 New York 200 London 300 Tokyo and then for the user to select the value 100 and for all data to be queried from account balances for cost center 100. Problem is ho

  • Error installing SOA Suite 10.1.3.1.0

    Hi, I am trying to install SOA Suite 10.1.3.1.0 in my PC (Window XP). But the installation fails with the following error message: "Caught exception running the command via the script file D:\product\10.1.3.1\OracleAS_1\bpel\system\services\install\a

  • ES_MM_XI_Content.tpz

    Hi All I have ES_MM_XI_Content.tpz file. How to upload this file into PI 7.1 EHP This is my requirement. Import XI repository and design object ES_MM_XI_Content.tpz. This file contains: - All RFC and IDoc metadata required for the integration - XI re

  • Can't open .jpg files in Key Note

    Why are my .jpg files grayed out in Key Note?  I've created slides before with .jpg files and don't know why I'm not able to do that now.