Selecting files of same color label in Applescript

I am trying to write a script that will move files to a new folder based on the color label of the files.  So basically I want all files with a Red label to go to one folder, all Orange label files to go to a different folder etc.  I am having a problem figuring out how to select files by their color label.  I want this to be automated and not require any user input.  I have searched forums and even bought a couple books on Applescript but haven't been able to find my answer.
Any information would be very helpful,
Thanks
Charles

racinrandall wrote:
However when I move the files to the remote folders, the original file is still in the original folder.
The move command does the same thing as drag and drop
Drag a file and drop it in another partition copy the file, you must press the Command key to move the file.
But there is no command in the AppleScript Finder Dictionary to do this.
First solution : the mv command in a do shell script :
tell application "Finder"
      my moveFiles((files in folder "myfolder" whose label index is 1) as alias list, folder orangeFolder)
      my moveFiles((files in folder "myfolder" whose label index is 2) as alias list, folder anotherFolder)
end tell
on moveFiles(tFiles, destFolder)
      set tDir to quoted form of POSIX path of (destFolder as string)
      repeat with i in tFiles
            do shell script "/bin/mv -n " & (quoted form of POSIX path of i) & " " & tDir
      end repeat
end moveFiles
-- the -n option after /bin/mv equal  (Do not overwrite an existing file and the original file will not be moved)
-- use -f option to replace an existing file
Second solution : copy, delete and empty the trash
tell application "Finder"
      with timeout of 0 seconds
            set orangeFiles to files in folder "myfolder" whose label index is 1
            if orangeFiles is not {} then
                  duplicate orangeFiles to folder orangeFolder without replacing -- or with replacing
                  delete orangeFiles -- move files to trash
                  empty the trash
            end if
      end timeout
end tell

Similar Messages

  • How to get the same colored labels as in the gmail web interface?

    Hi,
    I would like to get the same preview in Mail.app (with different colored labels) as in Gmail. Currently, my Gmail account in synced with Mail.app, hence I have access to all my mailboxes (hence all my labels). I would like to add a rule which reads as :
    if Message is in (gmail label mailbox)
    then Set color to (color)
    However, this feature doesn't seem to be here. Basically, how to automatically colored a message being in a given mailbox (to get a nice rainbow in my general Inbox).
    Thanks in advance!
    Damien

    I'm pretty sure you can't do that in Mail. If you do find out, post back—I'd like to know too!

  • I can select a rating and a color label for my images, but I can not sort by rating and color label.

    I can select a rating and a color label for my images, but I can not sort by rating and color label. when I click on the filter drop down, color label is not one of the options.  how do I get both ratings and color lables as an option to sort with.

    You can Filter (not sort) on both color label and rating if you want, open the Filter Bar with the backslash key, then click on Attribute, and then select the stars and color label of interest. If you really meant "sort" and not filter, then you can't do this in Lightroom.

  • Automator: Apply Color Label and Copy to Folder

    I'm trying my hand at Automator, and I need help with one of my workflows (⇪). Basically, it's a service (accessible via right-click) that will apply a color label on an image file, and then copy that image file to a corresponding folder with the same color label. My current version works fine, except for the fact that I had to create seven versions to accommodate all seven colors.
    Is there any way to turn the color into a variable? I want the workflow to prompt me for a color, and then use that choice to run a search for the appropriate folder. I'd rather not hard code the color choice into separate services that all do the same thing.
    Also, the service currently assumes that it will run fast enough before I can deselect the target file. I'm sure it's possible that the folder search could lag out while I select another file, and the service will ultimately copy the newly selected item, rather than the initial target. Is there a way to ensure the service acts on whatever was selected when it was first triggered?
    I don't know AppleScript beyond copying-and-pasting other people's codes, so that limits my automation quite a bit. I don't know how to prompt for a label index choice and then feed the result into a find function. I also don't know how to record the file path of the selected item, and then feed that into the copy function at the end to ensure it doesn't copy the wrong file.

    Typically a list of items is passed to a workflow, so you will usually (depending on what you are doing with the items) need to step through the items in that list. If there is only one destination folder with the target label, you can just search for it, otherwise you will need to specify the destination in some other way.
    The following Service workflow example assumes that there is only one destination folder that has a given label color. It gets the label index of one of the input items and finds a folder with the same index at a specified base location (to limit the search range).
    1) Input items are automatically passed to an application or service, otherwise another action to get FInder Items can be used
    2) *Label Finder Items* (show the action when the workflow runs)
    3) *Run AppleScript* (paste the following script)
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters} -- copy to a labelled folder
    This action is designed to follow a "Label Finder Items" action.  It will get the
    first folder of the base folder that has the same label and copy the input items
    to that folder.
    input: a list of Finder items received from a "Label Finder Items" action
    output: a list of Finder items to be passed on to a following action
    set output to {}
    set skippedItems to {} -- this will be a list of skipped items (errors)
    set baseFolder to (((path to pictures folder) as text) & "Shelley:Mary:") as alias -- a place to start looking for the destination folder
    tell application "Finder"
    set theLabel to label index of (the first item of the input) -- just pick one, they should all be the same
    get folders of (entire contents of baseFolder) whose label index is theLabel -- include subfolders
    -- get folders of  baseFolder whose label index is theLabel -- no subfolders
    if the result is not {} then
    set theDestination to the first item of the result
    else -- no folder
    error number -128 -- cancel
    end if
    end tell
    repeat with anItem in the input -- step through each item in the input
    try
    tell application "Finder" to duplicate anItem to theDestination
    set the end of the output to (the result as alias)
    on error number errorNumber -- name already exists, etc
    set errorNumber to "  (" & (errorNumber as text) & ")"
    -- any additional error handling code here
    set the end of skippedItems to (anItem as text) & errorNumber
    end try
    end repeat
    showSkippedAlert for skippedItems
    return the output -- pass the result(s) to the next action
    end run
    to showSkippedAlert for skippedItems
    show an alert dialog for any items skipped, with the option to cancel the rest of the workflow
    parameters - skippedItems [list]: the items skipped
    returns nothing
    if skippedItems is not {} then
    set {alertText, theCount} to {"Error with AppleScript action", count skippedItems}
    if theCount is greater than 1 then
    set theMessage to (theCount as text) & space & " items were skipped:"
    else
    set theMessage to "1 item was skipped:"
    end if
    set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {skippedItems, AppleScript's text item delimiters} to {skippedItems as text, tempTID}
    if button returned of (display alert alertText message (theMessage & return & skippedItems) alternate button "Cancel" default button "OK") is "Cancel" then error number -128
    end if
    return
    end showSkippedAlert
    </pre>

  • Changing color label of edits coming back from photoshop

    I am currently using lightroom 3.2 RC.  The issue is when sending a raw file out to photoshop then at the conclusion of editing as the file arrives back to lightroom, it now keeps it original color label (yeah), but if I now attempt to change it's color label from one color to another that I use to denote a completed PSD file, the file losses it color label completely and ends up without a color label at all (similar to what use to happen in 3.0), and I have to go find it and relabel it again.
    hopefully I explained that well enough to catch the fault that exists
    mike

    I only have PSE8 and not Photoshop, but I cannot reproduce this behaviour by externally editing a Raw file in PSE8 from LR. When using PSE, you have to have LR render the PSD on the way to PSE already, which is a difference to Photoshop.
    What technique are you using to assign the new color label when coming back from PS (keyboard shortcur, Metadata panel, ...)?
    I'm using LR3.2RC on WinXP SP3.
    Beat Gossweiler
    Switzerland

  • Lr5 lost/did not import my color labels

    My Lr4 calalog has all my color labels but when upgrading that calalog to Lr5 - all color labels on images are stripped and I see the label default (Red - Delete, etc)
    I went into the Roaming - Adobe - Lightroom folder and found "Label Sets" but I fear what is in there is the Lr5 stuff
    Question: How can I get all my Lr5 catalog images to have the same color labels as my Lr4 catalog?
    Thank-you

    If your label sets were stored properly in Lightroom 4 they are still in the correct folder in Lightroom 5.
    Go to Metadata>Color Label Set> and make certain the correct Label Set is ticked. If it isn't tick it. If it isn't there you will have to open your Lightroom 4 and find out where that Label Set is stored and move it to the proper place.
    How Labels work:
    Lightroom looks at the metadata of the Label field and matches the text against the five fields in the Color Label Set. If it matches one, it applies the color. If there is text and it doesn't match any, a White Label is applied. If it doesn't have text - no label is applied.
    Give your problem description, you should be seeing a bunch of White labels instead of no label. Is that happening?

  • Trouble with color labels not synching between different machines sharing same data drive

    Hi
    I am having a problem that seems to have come up when I started using a mix of PS/Bridge CS4 and CS3, in which color labels I apply in Bridge--primarily to folders--do not retain the color label when I look at the same set of folders on the same external hard drive using multiple, different Macintosh machines, running a mix of CS3 and CS4.  The color labels will appear on one machine and then not appear at all on another.  Note: they don't appear as white labels without a color.  It's as if they were never labeled at all!
    I use multiple Macs to connect to one primary external data drive.  I consistently configure Bridge to export caches to the external drive, and with CS3 any color labels I applied to folders were consistently displayed in the same way on multiple machines.
    Every since I upgraded a couple of my Macs to CS4, I now notice that color labels applied on one machine aren't showing up when I attach my external drive to other machines. I've even noticed a problem connecting to the external drive from two different user profiles on the same Mac laptop (running CS4).
    I have tried resetting the preferences and the cache on all of these machines.  I also then re-toggled the export caches checkboxes on all these machines.  Per some earlier troubleshooting, I have also made sure that the naming convention for the labels is the same on all the machines: "Approved" versus "Green," etc.
    There just seems to be no rhyme or reason for why the color labels are not synching.
    HELP!?
    Thanks in advance.

    I have no clue at all, labels should stay visible after having applied them
    to a file and used purge cache. And they do so on my system.
    Normally there will not be many reasons to use the purge cache option unless
    you have trouble, every time you alter a file it should be auto update the
    preview and thumb, is this not in your workflow?
    Are you still working with same files that were also present on your other
    system and using CS3?
    Have you considered to start from scratch?
    Quit Bridge, from the user library preference folder delete the plist file
    for Bridge to the trash and in the same library from the caches folder /
    Adobe/BridgeCS4 move the cache file outside the user library if you want to
    backup this file (or to the trash if you don't want it anymore)
    Both files will replace itself with fresh ones but the cache needs to start
    all over again building previews.
    Again hold option when starting Bridge first time and again choose refresh
    preferences.
    Set the preferences for Bridge to your wishes and try again.
      However, if I go to "Tools-Cache-Purge Cache For Folder" and purge the cache
    for the folder I'm working in, the color labels disappear.  Is this expected
    behavior?  Shouldn't the color labels be recreated?? Again, I have repeatedly
    purge the cache in this way, have reset Bridge CS4 settings, and have
    re-selected the option to "Export Caches To Folders When Possible."  What's
    going on!?!?!?  Thanks.

  • Can not color label more than one file at a time

    Hi,
    I've had this problem since 10.6.6-ish, i can not color label more than one file at a time in the Finder.
    Wether i select two, twenty or twohundred only one file gets color labeled.
    It doesn't seem to matter if i assign a color label through the File menu or right click > label.
    Figured a re-install might fix this but it hasn't (even a clean install without restoring any kind of backup).
    Does anyone else have this issue and/or a fix for it?
    Thanks,
    Jay

    Aaaaanyone ?

  • Finder does not show all colors from selected color Labels

    Since a view days finder does not show all Color Label colors. When I select either yellow or green it is selected, but it does not show in the file list with details, I can see it in icon and 3 pane view, but not in the detail list view.
    does anybody know why or how? Or what plist files I might need to delete to get this reset?

    Create a new account, name it "test" and see how your labels work in that User acct in list view? (That will tell if your problem is systemwide or limited to your User acct.) This account is just for test, do nothing further with it.
    Open System Preferences >> Accounts >> "+" make it an admin account.
    Let us know and we'll troubleshoot this further.
    -mj
    [email protected]

  • Change selected file to a file with same name but different extension.

    So I'm getting better at using Automator to create useful Services but still a bit of a newbie with doing powerful things with AppleScript... and I think this task requires some applescripting. Here's what I want to do:
    1. Based on a selected text file I want to run a pre-existing script that converts this file into an HTML file. This new file has the same name as the text file but has the .html extension rather than the .txt extension. (This step is easy enough and it works just fine already.)
    2. BUT NOW, I want to take that resulting HTML file and run another pre-existing script that converts the HTML file into an RTF file. The problem is that I basically want to change the selection from selectedfile.TXT to selectedfile.HTML so that I can proceed to this next step...
    3. AND THEN, I want to launch an app with this resulting RTF file. Again, I need to change the selection to selectedfile.RTF.
    Right now this requires me to run three different services, and changing the selected file between each step... But I'm sure there's an easy applescript way (or other way) to do this using just one service -- probably involves some filename parsing and some magic to change the selection??? -- or something like that...
    Could anyone point me in the right direction???
    Thank you thank you thank you!
    ~zyyyy

    You can chain your scripts together - depending on the complexity of your pre-existing scripts, you could do this with either AppleScript or Automator. The workflow would just take the selected text file (from step 1), convert to both HTML (2) and RTF (3), then launch your application with the resulting RTF - no need to change any selection.
    By the way, this is the Tiger Automator forum - Snow Leopard's Automator is quite a bit different, so you will probably have better luck posting in the Snow Leopard forum.

  • In a gradient mesh, I can't tell Illustrator to select all points that are the same color?

    All I can find online is to highlight over an area to select multiple mesh points. That will not work in my case. I can't tell illustrator to select same color, the way it does with fills and strokes? I want to change the color and I have to click on every single point again? Ridiculous.

    Edit>Edit Colors>Recolor Art
    You can assin colors an dhe recolor art filter will only read the color at the anchor points which I think is desirable
    Look at the very warm red color color and how I change it by assingin a new color in this case a blue. Read about the Recolr Art Dialog in the help files it is bit tricky at first but does  lot of good things.
    After you get the colors you want you can turn them into a color grpups as well and you will have the swatches in your swatch panel.
    Then if you have similar colors that you wish to cahnge the same color you can use the edit color wheel and move the color selectors over one another.
    Here I turend the warm red to a yellowish color as wellas the more orange color to match the new color .

  • Why doesn't the "Command Number" keyboard shortcut apply the colored label to the selected image?

    Why doesn't the "Command Number" keyboard shortcut apply the colored label to the selected image?  The similar keyboard shortcut to assign stars works, but the shortcut to assign a label color doesn't?

    Just to be sure they haven;t been reassigned in your Aperture go to Aperture->Commands->Customize then in the search box in the upper right hand corner enter color.
    You should see the keyboard shortcuts and the corresponding add label commands.
    If they are set then quit Aperture move you preference file to the desktop and restart Aperture. The instructions for moving the preference file can be found at Aperture 3: Troubleshooting Basics
    Post back the results
    Message was edited by: Frank Caggiano - Added preference file move

  • Applescript: Create a Folder from Files of Same Name but different Extension

    Hi guys,
    Racking my brain for the past 2 hours trying to figure out how to properly use Applescript but alas to no avail.
    My  problem is as follows.
    xxxxxxx.extension1
    xxxxxxx.extension2
    yyyyyyy.extension1
    yyyyyyy.extension2
    zzzzzzz.extension1
    zzzzzzz.extension2
    I've been trying to create an applescript that takes files of same name and create a folder with the name of those files grabbed.
    So ultimately it would look like
    xxxxxxx/
         xxxxxxx.extension1
         xxxxxxx.extension2
    yyyyyyy/
         yyyyyyy.extension1
         yyyyyyy.extension2
    zzzzzzz/
         zzzzzzz.extension1
         zzzzzzz.extension2
    Can some more more adept at this than me provide with a solution?  It would be great if I could use by just selecting the folder that contains all these files.
    Also can anyone suggest an beginner's book on Applescript?  I'm a bit or an order freak and Im sure applescripting could help me automate a lot of repetitive tasks Im currently doing.
    Thanks!

    This will do what you need.
    set source to (((path to desktop folder) as text) & "Test") as alias
    tell application "System Events"
                   set fnames to (name of every file of source)
    end tell
    set AppleScript's text item delimiters to "."
    repeat with fname in fnames
              try
                   set folderName to text item 1 of fname
                   if folderName is not "" then
                    tell application "Finder"
                      if not (exists (folder folderName of source)) then
                          make new folder at source with properties {name:folderName}
                      end if
                     move file fname of folder source to folder folderName of source
                 end tell
           end if
        end try
    end repeat
    (the code formatting here really s*?ks. select all the text in the box and right click and select services make new AppleScript to get it into the editor)
    It's not very polished so be careful, setup some test folders and make sure it does what you want before using it on your live data.
    You need to set the
    set source to
    line to the path of the folder where the files are. You can do that as an absolute path ie "Macintosh HD:Users:etc" or using the path to as in the example.
    It is also not very efficient and there are many different ways to attack this problem. If this is a one time thing this will be fine. If it will be an ongoing situation you might want to describe exactly what is happening and other ways to solve the problem might be possible.
    As for learning AppleScript start with the Apple Development Site, especially AppleScript Language Guide.
    There are lots of sites out there with good info MacScripter being one of the better ones.
    Book wise I really like Learn AppleScript by Apress. Its good as both a tutorial and reference and has a good intro to AppleScript Objective-C (a way Apple ahs setup to allow AppleScripts to access pure objective-c code and the OS X GUI).
    good luck

  • Change selected file in automator using applescript ???

    So I'm getting better at using Automator to create useful Services but still a bit of a newbie with doing powerful things with AppleScript... and I think this task requires some applescripting. Here's what I want to do:
    1. Based on a selected text file I want to run a pre-existing script that converts this file into an HTML file. This new file has the same name as the text file but has the .html extension rather than the .txt extension. (This step is easy enough with Automator and it works just fine already.)
    2. BUT NOW, I want to take that resulting HTML file and run another pre-existing script that converts the HTML file into an RTF file. The problem is that I basically want to change the selection from selectedfile.TXT to selectedfile.HTML so that I can proceed to this next step...
    3. AND THEN, I want to launch an app with this resulting RTF file. Again, I need to change the selection to selectedfile.RTF.
    Right now this requires me to run three different automator services, and changing the selected file between each step... But I'm sure there's an easy applescript way (or other way) to do this using just one service -- probably involves some filename parsing and some magic to change the selection??? -- or something like that...
    Could anyone point me in the right direction???
    Thank you thank you thank you!
    ~zyyyy

    Have you considered using a bash script? You can even write the script in an Automator Service.
    Open Automator and select Service from the main screen. Set the ‘Service Receives Selected’ pop-up menu to Files or Folders, and set the ‘in’ pop-up to Finder. Drag Run Shell Script from the Utilities section of the actions library into the workflow area. Set Pass Input to As Arguments. Replace the sample code in the input area with this:
    for f in "$@"
    do
    file_ext="${f##*.}"
    if [ $file_ext = "txt" -o $file_ext = "TXT" ] ; then
    /usr/bin/textutil -convert html "$f"
    /usr/bin/textutil -convert rtf "${f/$file_ext/html}"
    /usr/bin/open -a /Applications/TextEdit.app "${f/$file_ext/rtf}"
    fi
    done

  • How can I select same color shapes in adobe flash program ?

    how can I select same color shapes in adobe flash program ? for example we assume 10 rectangle shapes . 3 of them are red others are green. I want to use only one click or method to select 3 of them. please help me
    thanks kunter

    that is not possible unless they are all grouped into one symbol or movieclip

Maybe you are looking for

  • Unable to do mobile printing with HP Deskjet 3050 All-in-one J610a (CH376D)

    I have a 3050 All-in-one J610a which I am using for about an year now. In the beginning I was able to print/scan using HP app (probably HP home & Biz) on my iPhone4 but for past few months i didn't use it but kept updating the app to the latest versi

  • Reject error Invoices

    Hello, We have a scenario where, sometimes for a given PO we receive the invoice from the vendor before we receive the GR. Then, after we receive the invoice, if someone decides to cancel the order they go ahead and delete all the PO line items. And

  • Common report name for all Function modules??

    Hi.....     If we check the value of the SY_CPROG in the sourse code of the any function module we can get RS_TESTFRAME_CALL as value. From SE38, if we excute this report we can get one selection screen-> there we can give the FM name and we can excu

  • How do I replace the proxy files in my edited multicam sequence?

    I have edited the sequence with a proxy MULTICAM clip. Now I want to replace the proxies with the hi-rez media. I can replace footage in the individual A-B cam clips but how do I replace the footage in the multicam clip so it automatically updates in

  • The cluster resource could not be brought online by the resource monitor.

    I'm installing Exchange 2007 CCR at a set of Windows server 2008 Virtual Machines. When I refer the doc to Configure the Node and File Share Majority Quorum, at the step 3 -  Bring the new File Share Witness resource online by running the following c