Folder action - rename & colorize new files

Hello,
to help myself handling / managing my incoming aka download folder i am trying / willing to write a script which does some automated tasks for me.
a) unquarantine (solved)
b) rename - add date/time(yyyymmdd) in front of the filename (open)
c) label them with colors (open)
*General question:*
Well right now i am wondering about some general points first:
Is it better to split that into 3 sep. folder actions scripts which would be attached to the same folder ... .no idea if that may result in problems regarding which script goes first.... or should i add it to a single script ?
*Regarding a)*
i found this post here:
http://henrik.nyh.se/2007/10/lift-the-leopard-download-quarantine
on adding folder items to thisFolder after receiving addedItems
repeat with anItem in addedItems
set anItem's contents to (quoted form of POSIX path of (anItem as alias))
end repeat
set AppleScript's text item delimiters to " "
do shell script "xattr -d com.apple.quarantine " & (addedItems as text)
end adding folder items to
which explains an unquarantine routine ... works pretty good. I have just added a growl routine at the end for my personal use
*Regarding b)*
I'm not really sure how to handle the date_idea in applescript. I know i could use "do shell script" and save the output of date to a variable but i hope there are better methods to get the name in my desired format (yyyymmdd)
And how would you realize the rename-action itself in applscript ?
*Regarding c)*
I guess "set label index of myFile to 1" is the correct comd here for Finder. Or would you suggest any other method ?
any help is appreciated
best regards
fidel

Is it better to split that into 3 sep. folder actions scripts which would be attached to the same folder ... .no idea if that may result in problems regarding which script goes first.... or should i add it to a single script ?
A single script, for sure.
If you have three separate scripts you will encounter a race condition were all three scripts are trying to run at once. This is asking for trouble, especially when one of the scripts renames the file making it impossible for the others to find it (e.g. they start off looking for 'download.doc' but by the time they do their thing that file has been renamed and no longer exists).
i found this post here:
(snip)
That code, as written is fatally flawed. I can't believe it works.
First of all it starts off by looping through the addedItems, which is fair enough, but it doesn't do anything worthwhile within the loop - It just converts anItem to a POSIX path, but doesn't do anything with the result. It goes on to set the text item delimiters, but doesn't restore them later.
Finally it calls do shell script, but not in a way that will work. You cannot pass addedItems as-is because it is not in a format that will work in the shell.
I'm not really sure how to handle the date_idea in applescript. I know i could use "do shell script" and save the output of date to a variable but i hope there are better methods to get the name in my desired format (yyyymmdd)
Ironically I would go for a shell-based approach to get the date, mainly because simple date formatting like this is far easier in the shell than in AppleScript (it can be done in AS, but takes multiple lines of code).
I guess "set label index of myFile to 1" is the correct comd here for Finder. Or would you suggest any other method ?
set label index is the way to go, for sure.
So putting the above together you'll end up with something like:
on adding folder items to thisFolder after receiving addedItems
  set theDate to do shell script "date +%Y%m%d"
  repeat with anItem in addedItems
    do shell script "xattr -d com.apple.quarantine " & (quoted form of POSIX path of (anItem as alias))
    tell application "Finder"
      set label index of anItem to 1
      set name of anItem to (theDate & (name of anItem as text))
    end tell
  end repeat
end adding folder items to

Similar Messages

  • Change Tiger default Folder Action to parse all files in folder?

    I'd like to be able to use Automator and OSX Tigers Folder Actions to parse all files in a folder to an automator workflow, but it seems the default is that Folder Actions just pass the newest file added to a folder. Is it possible to modify the default applescript that says something like open_added to open_all? Sorry, not an applescripter so don't shout at me. What I'm trying to do is get automator to construct a variable URL from various txt files in a folder. I'm using the txt files as variables as Tigers Automator doesn't seem to be able to use variables or save and combine a result.

    That is the way that folder actions work. You can edit the AppleScript wrapper that Automator makes for your folder action, though, since the folder action handler also returns an alias to the attached folder.
    If you look in your user's *~/Library/Scripts/Folder Action Scripts* folder, the folder action script for your workflow looks something like this:
    <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;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on adding folder items to this_folder after receiving added_items
    tell application "path:to:your:workflow.app"
    open added_items
    end tell
    end adding folder items to
    </pre>
    By changing the line open added_items to open {this_folder}, the script will pass the folder instead of the files, so you can then use that in your workflow (e.g. *Get Folder Contents*, etc).

  • How to rename back to files instead of folder artist / song

    Hello,
    I have folder full of mp3 that I want to simply be organized by file. In playing around with iTunes, I pointed it to that folder and it did a mass reorganization of all of my mp3s into the classic artist / album / song when all I want is the way it was with a list of all files and not in folders. I plan to copy these into the iTunes music folder so they can be organized that way.
    How do I "undo" what iTunes did and get it back to the way it was? This did not happen by iTunes copying the files since I pointed iTunes directly to that folder, it renamed my actual files. This is an error on my part, but there has to be a way to undo this (nope, don't have a backup copy or anything since I didn't think iTunes would actually modify my files).
    Thanks!

    I found MusicBrainz tagger and will give that a shot, but I'm sure it won't get many songs.
    MusicBrainz is the only really good way to take a bunch of unorganized files and tag them properly. However, I've found that it's actually quite good. It gets about 60-70% without any intervention, and the rest it will make a best guess and and let you confirm whether it's guess was correct. It isn't exactly the simplest program in the world to use though, but works quite easily once you get the hang of it.
    Sign up for a musicbrainz account before using the tagger. You really need an account to use the manual features of the program.

  • Finder - Create new files directly from a folder using finder ?

    In Finder, is there a way to do a right-click in a folder and create a new file like: New Text File or New Document from that location?
    I used to do this oftenly in Windows (right click, New Word document) but I have not found it in Mac OS X, any work around ?
    Thanks

    Try the [Apple feedback page|http://www.apple.com/feedback>. However, note that this is unlikely to be added. It would be a very cumbersome feature.
    On Windows, you're almost guaranteed to be tied to a particular set of document creation tools. If you're using an office suite other than MS Office, you're so weird you might as well be using a Mac! This means that commands like "New Document" make sense there.
    On a Mac, a "document" could be created with MS Word, Pages, TextEdit, NeoOffice, OpenOffice, Mellel, Nisus Writer Marinter Write, or any of a host of other programs. (Mac users tend to put less emphasis on the popular tool and prefer to use the tool that "fits the hand" best.) Further complicating things is the fact that "document" is a very generic term, since every spreadsheet is a document, every Photoshop file is a document, etc. The contextual menu would rapidly become unmanageable if it had to fill up with "New Whatever Document" commands for every app on your hard drive!
    It is possible for you to add your own custom services to the contextual menu using AppleScript or Automator, and you should be able to create services to create new documents for the apps you use frequently. Check on the [AppleScript forum|http://discussions.apple.com/forum.jspa?forumID=724] for guidance on how to do this.

  • Copying modified files with Folder Actions

    Hi,
    I'm not sure if this is the right place to ask this so please tell me if it isn't!
    I need to set a folder action where any time a file within a specified folder is modified, I want it to be duplicated to another folder elsewhere on the computer. Does anybody know how I would go about this bearing in mind that I know nothing about applescript?
    Many thanks,
    Paul.

    You may be able to set up a watched folder with some shell scripting, but there isn't a folder action for when a file is modified. The available folder actions are:
    adding folder items to - invoked after items are added to its associated folder
    closing folder window for - invoked after a folder’s associated window is closed
    opening folder - invoked when its associated folder is opened in a window
    removing folder items from - invoked after items have been removed from its associated folder

  • Issue with folder action created with automator

    Hello all,
    I'm having an issue with folder actions that i created with automator and it's driving me crazy. Apple says they can't help with things created by the user so this is my only shot at figuring this out.
    Running a Mini 2.3G quad i7, 8GB ram on OSX Mavericks 10.9.2
    My goal is to set up an action to add text to the filename of a file placed into a particular folder. So I open automator and choose folder action. Then I choose the folder I want the action applied to at the top. Then I go to Files and Folders in the library and choose rename finder items and drag it over to the workflow. I select add text, then add the text I want added to the file name and choose before name because I want the added text to preceede the original filename text. I save it then go to the folder I applied it to and right clikc go to services then folder actions and verify that the service is attached to that particular folder and it is.
    Should work right? No. When I place a file in that folder the action runs and adds the text like I want it to... but then it starts to add it over and over again in an infinite loop. It also adds a file with the extension .ds_store to the folder that also has the name added over and over.
    I've tried deleteing all the folder actions and even deleteing all the folder actions themselves saved by the automator in the workflow file in the user library.
    I'm stumped... no idea what to do. A while ago I had used the automator to batch rename files and it worked perfectly. I tried the same steps i listed above to set this action up on a machine in an Apple retail store and it worked... so I know I have the set up right.
    Any help is greatly appreciated.
    Thanks,
    Justin

    Hi JK257
    This is why it happens:
    The folder action is looking for new items in the folder. You drop in a file called "File1". So it renames it "sometext File1". Then it sees this new file called "sometext File1" and thinks "Hey, this is a new file - I'll call it 'sometext sometext File1' because I have to rename every new file." Then it sees this new file called "sometext sometext File1" and thinks...
    You get the picture.
    (the .ds_store is a normally hidden database file which is getting revealed by the same process.)
    The solution is to move the files out of the renamer folder into a receiving folder after they have been renamed:
    Hope this helps,
    H

  • How to set up Automator Folder Actions?

    I have set up and sucessfully tested a workflow which sends any file found in a particular folder to the "paperless" app, then moves all files to a different folder called "Archived attachments".
    HOWEVER as a folder action,  nothing happens when a file is put into the folder. The file just sits there in the folder.
    To create a folder action I opened  "new folder action" in Automator, then dragged and dropped the working workflow file into the workspace, then set "Folder Action recieves files and folders added to" the appropriate folder, let's call it "Attachments".
    Just to complicate things, the files are placed into the "Attachments" folder using an applescript that captures all pdf mail attachments. This applescript works succesfully.
    So, where could I be going wrong?
    The working workflow "Attachments.workflow" consists of:
    Get Specificed Finder Items
    Make Sequential
    Get Folder Contents
    Open Finder Items
    Get Folder Contwents
    Label Finder Items
    Get Folder Contents
    New Dated Folder
    The erronious Folder Action consists of:
    Run Workflow (Attachments)
    In folder actions setup:
    "Enable Folder Actions" is ticked
    "PDF Attachments" folder is ticked
    "Attachments_folder.workflow" script is on.

    I'm confused. You showed two Automator actions with the same name, one was a folder action one wasn't.
    Are you sure the correct Automator action (the one that is a folder action) is attached to the folder?
    If when the Folders Action setup window is opened and you select Articles_Folder.workflow and then edit script are you getting the right workflow?
    Assuming you do I would start off very simply. Try this:
    It will label green screen shot image files saved to the Desktop.
    See if this works for you.

  • Problem running multiple folder actions at the same time

    Hi,
    Does anyone have some experience running multiple folder actions at the same time?
    I've written a Applescript folder action that processes some files. When adding some files, the script starts and all goes well. The processing of each file takes a few minutes, but all files are processed correctly.
    However, when adding some new files to the dropfolder, while the folder action is all ready processing other files dropped a few minutes earlier, the process that is all ready running immediately aborts and the folder action is relaunched on the new files, leaving the old files for what they are...
    The same problem occurs with multiple folders, each having a folder action attached. When dropping files in "Folder A", the script starts processing. But if someone droppes files in "Folder B", The script of folder A aborts, and the script of folder B starts processing. When adding more files to the folders, the result is the same. In some casses, when the last dropped files are processed, the os continues where the operation was aborted on the previous files. But this not always happens. To make things worse, when you remove the items from the folders afterwords, the folder actions starts running again on items no longer present in the folder !!!!
    Does anyone know how I can prevent the folder action being aborted when new files are dropped and placing the new files in "Hold", until the previous files are processed? How can I prevent a folder action being aborted when a item is dropped into another folder?
    I've written a small script to test this behaviour. Just create one or more folders and attach the script below. Drop a item into the folder, wait a few seconds and drop another one in the same or another folder. To monitor what happens please check the console.
    on adding folder items to this_folder after receiving added_items
              set FolderName to this_folder as string
              set ItemName to added_items as string
              repeat with theIncrementValue from 1 to 15
      delay 2
                        do shell script ("logger \"Folder: " & FolderName & "  -  Item: " & ItemName & "  -  Step: " & theIncrementValue & "\"")
              end repeat
              do shell script ("logger \"Folder: " & FolderName & "  -  Item: " & ItemName & "  -  Done...\"")
    end adding folder items to
    Thanks for any feedback.

    That is pretty much the way Folder Actions work, especially since AppleScript is not multi-threaded.  If you are using them as some intermediate step in a workflow, you might rethink the way you are handling the files (for example, use a droplet instead).  Other options would be using launchd to watch a path or a shell script on a different thread.

  • Need help with simple folder action or script

    I have created an export preset in Lightroom that exports images to a folder called "To Email" on my hard drive, and then automatically attaches those images to a new email in my email client (Mailplane).
    It's a great solution that allows me to send a photo via email with one click from Lightroom. However, I want to take it a step further by creating a folder action or script that automatically deletes the image after it is attached to the email. This will allow me to put the folder somewhere deeper in my file system without having to worry about cleaning it out all the time.
    Unfortunately, I have no experience with Automator or AppleScript. Can you help? Thanks.

    I think you need to rework elements of your workflow.
    For example, you say the export preset creates and sends the email.
    If this is the case, the the logical place to make your change would be to edit that preset action (I don't have Lightroom to know whether this is an option there or not).
    The problem with using a Folder Action is that the Folder Action will trigger when the file is dropped in the folder, but that will be before the email is generated or sent, so you run the risk of deleting the file before it's sent.
    So if you can't edit the export preset to do the deletion I would suggest decoupling the 'send an email' and 'delete file' elements from the Lightroom action - in other word change Lightroom to just export the file, and have a separate folder action that triggers when files are added to that folder. The folder action script can take care of generating the email and sending it out, knowing when the email is sent and therefore when it's safe to delete the file.
    WIthout seeing more of the current workflow it's not easy to be more specific.

  • Folder actions question

    I would like a folder action that takes a file that I drag and drop to it to be attached to an email and sent to a specific recipient with out any further intervention
    Can that be done ??

    I had a bit of a problem with this but I think I've got it
    Create a new folder to contain your files - this seems to work best from the desktop
    In Automator use the Finder "Choose Folders" command and select the fiolder from the drop down, tick "return references to the folder contents"
    Drag Mail's "New Mail" command below and input the address you want in to the to section. Tick "attach items" , I can't get the "send mail' option to work here it always reports an address error for some reason, I have tried attaching the "Send Outgoing Mail" action to the end too, but this also won't work for me.
    Still it will at least create the message and only require you to press send - will investigate more and see if I can fix it.

  • How do i set a default group (not staff) for new files?

    by default, new files created from within applications appear to be assigned group "staff", regardless of the folder in which they are being created.
    i want new files to inherit the group of the folder in which they are being created. if i create a new file from the terminal command-line, this works. note that it also works when creating new folders from the finder and "save as" dialogue boxes.
    how do i get this to work for new files saved from all applications?
    thanks.

    I usually use the .NET method myself, but if I were forced to poll I would do something like this.  I use a variant to hold the list of filenames.  I would only poll the folder info, when it has been modified then do the Folder List.  Any new files are spotted when the variant attribute does not exist (Replace = FALSE), and this is added to the array.

  • Create folder action in automator

    I want to create a folder action that will move downloaded website backups into a specific folder.
    I cribbed the automator folder action shown below from Macworld
    The Folder Action appears not to work when left to just monitor the folder.
    However, if I force the Action to run from within automator it works, albeit with an error message at the beginning saying that you can't execute the action from within Automator. Still it finds the file and moves it to the intended destination.
    By way of checking this I looked at the "Set Up Folder Action" by right clicking on the downloads folder. After clicking there is a long delay but when the panel opens there is no content, see second image below. I tried clicking the + button to add the "Downloads" folder but after a long delay the "Open" dialog closes and nothing has appeared in the panel. I assume that any folder action should show up in this panel, but I've no experience in using it.
    Any suggestions as to a problem with the Action or why the panel is blank and why I can't attach the Action using this setup panel?
    Thanks
    Folder Action
    Note: Path and File have been omitted.
    Note: OS X 10.10.2
    Folder Action Setup

    I'm confused. You showed two Automator actions with the same name, one was a folder action one wasn't.
    Are you sure the correct Automator action (the one that is a folder action) is attached to the folder?
    If when the Folders Action setup window is opened and you select Articles_Folder.workflow and then edit script are you getting the right workflow?
    Assuming you do I would start off very simply. Try this:
    It will label green screen shot image files saved to the Desktop.
    See if this works for you.

  • When Photoshop CS6 is invoked from PSE 11 Organizer why is a new file created with _edited-1 appende

    I just converted a large PSE 10 catalog to work with a downloaded trial version of PSE 11.  When I brought up the Organizer and clicked on the Editor button I selected Photoshop CS 6.  At that point the Organizer created an image stack with a new file on the top of the stack that had a file name that was the original file name with "_edited-1" appended to the end of it.  Is there any way to avoid this?  For me it is going to create a tedious step to delete the original file and rename the new file after editing.  For probably 98% of my editing I will use only the Adobe Camera Raw editor on my imported raw files (Nikon's .nef).  ACR puts the editing data in a sidecar .xmp file so there's no need to protect the original file from be mistakenly replaced by an edited version.

    That's not a new behaviour : in old versions choosing the external editor did create a copy in a version set.
    I don't have CS6, so I can't be specific, but I wonder why you should open CS6 if most of your images can be edited in ACR. For them, you only need to click 'Done' and that saves the edits in the xmp sidecar file. I guess most of the remaining files could be processed in the PSE11 editor and saved in any image format (jpeg, tiff, psd...). Only a minority would have to be processed in CS6***, and in that case, creating a new copy in a version set seems quite reasonable.
    Edit:
    *** in CS6 or the full ACR version of CS6. In my case, it's very rare that I need the other tabs in ACR.

  • What does this simple folder action not work?

    OK I have been playing with this all weekend. I just wanted a simple folder action to move a file from folder a to folder b. There is really not much to it. The workflow works just fine. "Somtimes" running the script runs the workflow.app. However when I drop a file into folder a - nothing happens. I have enabled folder actions. Can anyone help?
    here is a pic of the relative screens that should help you.
    http://flickr.com/photos/hawsnet/2605303472/sizes/l/
    Thanks for any help you can provide.
    PS I even stopped by my local Genius Bar -- they could not help.

    Vantive,
    Try either:
    *on adding folder items to this_folder after receiving added_items*
    *tell application "Finder"*
    *repeat with this_item in added_items*
    *move this_item to folder "Folder B" of folder "Desktop" of folder¬*
    *"MyShortName" of folder "Users" of the startup disk*
    *end repeat*
    *end tell*
    *end adding folder items to*
    Or:
    *on adding folder items to this_folder after receiving added_items*
    *tell application "Finder"*
    *repeat with this_item in added_items*
    *move this_item to "Macintosh HD:Users:MyShortName:Desktop:Folder B"*
    *end repeat*
    *end tell*
    *end adding folder items to*
    In either case replace MyShortName with your actual short name. +Make sure the script is saved to your Home/Library/Scripts/Folder Action Scripts folder.+ Then right-click or control-click on "Folder A" and, if necessary, select "Enable Folder Actions." If enabled, right-click or control-click on "Folder A" and select "Attach a Folder Action…" When the Choose-a-File window appears highlight the script and press Choose.
    Both of the above scripts worked for me in testing. For what it's worth, both my /Library/LaunchAgents, and /System/Library/LaunchAgents folders are empty.
    Good Luck...
    Regards, Andrew99

  • Folder actions: apple scripts translation possible?

    I wonder if the script to automate a folder action, (eg. "new item alert") could be translated into another language, that's to say, is it possible to change the english sentence "add item" into the italian "elemento aggiunto" ? I open the applescript editor but I don't dare to modify any sentence before some expert can reassure me about the safety of this operation.
    Thank you

    You should always work on a copy, or make a copy and store it elsewhere, in case you get into difficulties.
    As regards the alert script, you can modify anything appearing between double quotes: these pieces of text are the displayed items and won't affect the running of the script.

Maybe you are looking for

  • Installing itunes to an external hard drive

    There are similar topics about this but none that answer the question. I do not wish just to move my library to an external hard drive as other posts have assumed. I wish to install the itunes application to an external hard drive so it can be run on

  • OCI compatibility - will program build using 8.1.x libs work on 7.3 client?

    I am building an OCI program on Linux and Solaris, linking OCI statically using Oracle 8.1.6. Even with a static link, the resulting program requires libskgxp8.so - which apparently has no static version. My question is this - will my program work on

  • How to skip screens in a transaction

    I m using transaction CU01, from the program i have to go to the third screen by skiping the first two,, is there any syntax for tht. I know how to go directly for second screen the syntax for tht is call transaction 'CU01'  and skip first screen. No

  • Acrobat Hangs With Vista

    Right now running Vista Business Premium (fully updated) and acrobat standard (8.1.1). We have some forms which we fill out then save as pdf's to print when needed. 99% of the time, when selecting addresses [from a drop down in the from] or a date ac

  • WF badi

    Hi all, We have identified that n-step(6-steps) approval workflow BADI needs to be activated.We are working on SRM 4.0,R/3 4.6C. I have the organization plan where the users have have been integrated.I have assigned the roles of employee and manager