Folder action adding date to added file

I need to write a folde action that will add the date to a files name after it is added. can anyone help here. here is what I have done but the file still does not get named correctly.
set m to month of (current date)
set d to day of (current date)
set y to year of (current date)
if month of (current date) is January then
set m to 1
else
if month of (current date) is February then
set m to 2
else
if month of (current date) is March then
set m to 3
else
if month of (current date) is April then
set m to 4
else
if month of (current date) is May then
set m to 5
else
if month of (current date) is June then
set m to 6
else
if month of (current date) is July then
set m to 7
else
if month of (current date) is August then
set m to 8
else
if month of (current date) is September then
set m to 9
else
if month of (current date) is October then
set m to 10
else
if month of (current date) is November then
set m to 11
else
if month of (current date) is December then
set m to 12
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
set theshortdate to m & "/" & d & "/" & y as string
--display dialog theshortdate
set source_folder to "Macintosh HD 2:Users:Edit2:Desktop:test"
tell application "Finder"
--set theFile to every item in folder source_folder
set old_name to "123"
set new_name to old_name & ".scpt" & " " & theshortdate as string
set name of file "Macintosh HD 2:Users:Edit2:Desktop:test:123.scpt" to new_name as string
end tell

this thing keeps repeat forever and adding the 11-1-07 date to the file name over and over, I cant figure out why
on adding folder items to this_folder after receiving added_items
set m to month of (current date)
set d to day of (current date)
set y to year of (current date)
if month of (current date) is January then
set m to 1
else
if month of (current date) is February then
set m to 2
else
if month of (current date) is March then
set m to 3
else
if month of (current date) is April then
set m to 4
else
if month of (current date) is May then
set m to 5
else
if month of (current date) is June then
set m to 6
else
if month of (current date) is July then
set m to 7
else
if month of (current date) is August then
set m to 8
else
if month of (current date) is September then
set m to 9
else
if month of (current date) is October then
set m to 10
else
if month of (current date) is November then
set m to 11
else
if month of (current date) is December then
set m to 12
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
set theshortdate to m & "-" & d & "-" & y as string
tell application "Finder"
display dialog theshortdate
set n to count items in added_items
display dialog n as text
repeat with an_item in added_items
set file_name to name of an_item as string -- get the current name
--display dialog file_name as string
set newname to file_name & " " & theshortdate
--display dialog newname
set name of an_item to newname as text
end repeat
end tell
end adding folder items to

Similar Messages

  • Folder Action on Modification of a File

    How do I get a Folder Action to run when a file is modified, not just when one is added?

    you can't. The only available folder action handlers are:
    adding folder items, removing folder items, opening folder, closing folder window and moving folder window.
    you can do this for individual files by creating launch daemons but that's probably not what you want as you'd have to create a separate launch daemon for each file in your folder.

  • Change folder name to Date 'n' moving files

    Hi Folks,
    I know how to create a folder ,now i want to create a folder with system date.And also wants to move files(which are in a seperate folder)to that folder.
    Thnx in advance..
    Cheers,
    smith

    to get the system date, use Calendar.getInstance(); which will give you a calendar that you can turn into a date easily
    to move files, use method renameTo in class File

  • Design Manager : Access Denied when renaming folder or adding files

    Good day my apologies if this question has been answered elsewhere .
    I have a SharePoint Online subscription. I am trying to upload my design files to the master page folder on the SharePoint site, but I keep on getting access denied errors. I have managed to map a drive to my masterpage folder via explorer, and I am able
    to create a folder, but I cannot rename the folder or copy my design files.
    I am not logged into my server using the office365 admin account, but I have mapped the drive with the credential, I have also added the admin account as site owner.
    Any ideas where I could look for the problem will be appreciated.
    regards

    You can try -
    Remove currently mapped drive
    Make sure that you're authenticated to Office 365.  In Internet Explorer,
    Sign in to the SharePoint Online site by using your Office 365 account credentials, and make sure that you click to select the Keep me signed in check box.
    Make sure that the SharePoint Online URLs have been added to your Trusted sites zone in Internet Explorer.
    And re-Mapped SharePoint Library - Please follow this Microsoft article -
    How to configure and to troubleshoot mapped network drives that connect to SharePoint Online sites in Office 365
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • 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).

  • 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

  • Folder Action + Move Finder Items = Zero KB files

    I've got a folder action set that is supposed to run the Automator Action "Move Finder Items" on any file that gets placed in a specific folder (called "Folder A") and move it to "Folder B". I'm having an issue with larger files though.
    As soon as I begin to transfer the file to "folder A" , the folder action runs and results in a "Zero KB" file in "Folder B".
    Is there any way to keep the Folder Action from triggering until the file has completely copied to the folder with the Folder Action attached ("Folder A")?
    A side note: I have this same folder action running on an iMac with Mac OS 10.6.3 and it works great . (This one was made with the newer version of Automator that shipped with 10.6 vs. Automator on 10.5 which made the action I am having trouble with)
    Any input would be appreciated!

    There is a check in *Snow Leopard* to see if the items have completed their copy/download, but Leopard does not do any checking - the script is triggered immediately. You can add your own delay with a *Run AppleScript* action, though, for example:
    <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} -- wait for file copy to complete by testing the size of the containing folder
    set theFolders to {} -- to handle items in different folders
    set skippedItems to {}
    repeat with anItem in the input -- get a list of unique folders
    tell application "Finder"
    get (container of anItem) as alias
    if the result is not in theFolders then set the end of theFolders to the result
    end tell
    end repeat
    repeat with aFolder in theFolders
    set timeToWait to 30 -- time to wait for copy to complete
    set interval to 2 -- test every interval seconds
    set copied to false
    tell application "Finder" to set currentSize to size of aFolder -- get initial size
    repeat with timer from timeToWait to 1 by -interval -- check every interval seconds up to maximum time
    delay interval
    tell application "Finder" to set newSize to size of aFolder -- recheck size
    if (newSize is equal to currentSize) then
    set copied to true
    exit repeat -- success
    else -- update size
    set currentSize to newSize
    end if
    end repeat
    if not copied then set the end of skippedItems to quoted form of (aFolder as text) -- timed out
    end repeat
    showSkippedAlert for skippedItems
    return input
    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 waiting for items to copy", count skippedItems}
    if theCount is greater than 1 then
    set theMessage to (theCount as text) & space & " folders timed out"
    else
    set theMessage to "1 folder timed out"
    end if
    set theMessage to theMessage & " - copy of contents may be incomplete:"
    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>
    The action will check the folder sizes, and when there is no change (or the wait times out) the input items are passed on.

  • Folder action kicks in too early

    I have a little applescript that is to add all files that are added to a specific folder to an iTunes playlist.
    I added the script as a folder action to the folder.
    It seems to work fine with single files.
    However, when I copy several files (which takes a few seconds), then the script gets started too early, i.e., when only half of the files have been copied over. Consequently, only some of the files get added to the playlist.
    In addition, when I copy a large number of files, it doesn't seem to work at all.
    Any ideas what's wrong? or what I can do?
    (Is this a bug in Mac OS? I read about an issue in 10.5 where folder actions got started before a single files was finished copying, but I haven't seen of any hints about my problem.)
    Any kind of help will be highly appreciated.
    Best regards,
    Gabriel.
    PS:
    Here is my script, for completeness
    Automatically add the files that are dropped on this applescript to
    playlist named below.
    To adapt it for a different playlist, just change the name below and save as application.
    In addition, you can add this script as a folder action
    Author: Gabriel Zachmann, Feb 2010
    property playListName : "Hoerspiele"
    on open theseFiles
    addTheFiles(theseFiles)
    end open
    on adding folder items to this_folder after receiving added_items
    addTheFiles(added_items)
    end adding folder items to
    to addTheFiles(theFiles)
    tell application id "com.apple.iTunes"
    activate
    set playL to some playlist whose name is playListName
    set playID to persistent ID of playL
    --display dialog ("persistent ID = " & playID) buttons {"OK"} default button 1
    reveal (some playlist whose persistent ID is playID)
    repeat with aFile in theFiles
    try
    add aFile to some playlist whose persistent ID is playID
    end try
    -- set new date, so we know later when we copied the files
    set the file_path to the quoted form of the POSIX path of aFile
    do shell script ("/bin/touch " & file_path)
    end repeat
    end tell
    end addTheFiles
    Message was edited by: GabrielZ

    folder actions have always been buggy and this has always been an issue when folder actions have to process many files at the same time. it's supposed to have gotten better in snow leopard but it's still very far from being reliable. you can try the following trick to slow down your folder action and make it wait to process individual items before they are all copied. that might (or might not ) help
    http://discussions.apple.com/message.jspa?messageID=8277780#8277780

  • 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.

  • Can't Get Folder Action To Work...

    Hi guys.  I'm working on an Applescript -- a Folder Action, to be precise -- which will, when files are dropped onto or added to my Downloads folder, automagically sort them into pre-existing folders, depending upon what kind of file they are.  But for the LIFE of me, I simply cannot get it to work.  I attach the script to the Folder using Configure Folder Actions (or as it appears in the context menu, "Folder Actions Setup"), and then drop files onto the folder and . . . nothing.  But I know that Folder Actions themselves are working, because I have a few others that I wrote myself that are working just fine.  I tried repairing permissions, but that didn't do any good.  Any ideas?  Here's the code below.   You'll notice that there is a section that's been commented out; mainly because I couldn't figure out how to do it without using recursion, and thus breaking up the script into subroutines, which I've heard you're not supposed to do with Folder Actions.  If someone could please explain what the heck I'm doing wrong and possibly provide a solution, I'd be really, really appreciative.  Anyway, the code:
    on adding folder items to this_folder after receiving these_items
    set imageTypesList to {"JPEG image", "Portable Network Graphics image", "Windows bitmap image", "Graphics Interchange           Format image", "Adobe Photoshop File", "TIFF Image"}
    set audioTypesList to {"MP3 audio", "AIFF-C audio", "Waveform audio"}
    set videoTypesList to {"Video-MPEG4", "MPEG-4 File", "Video-MPEG2", "Video-MPEG", "AVI", "Matroska Video File"}
    set fontTypesList to {"TrueType font", "PostScript® Type 1 outline font", "Font Suitcase"}
    set docsTypesList to {"Portable Document Format (PDF)", "Scrivener Project", "Microsoft Word 97 - 2004 document", "Rich Text           Document", "Plain Text Document", "CSV Document", "Pages Publication"}
    set epubTypesList to {"epub", "Kindle Document", "iBooks Author Template", "iBooks Author Book"}
    set archTypesList to {"ZIP archive", "tar archive", "rar archive", "Tar Gzip Archive"}
    set diskTypesList to {"Installer package", "Disk Image"}
    set execTypesList to {"Application (32-bit)", "Application", "Unix Executable File"}
    set webTypesList to {"HTML document", "XML document", "XHTML document", "Cascading Style Sheet"}
    set iconTypesList to {"Apple Icon Image", "Icon Container", "Windows Icon Image"}
    set otherTypesList to {"XTorrent File"}
    set uberList to imageTypesList & audioTypesList & videoTypesList & fontTypesList ¬                      & docsTypesList & epubTypesList & archTypesList & diskTypesList & execTypesList ¬
               & webTypesList & iconTypesList & otherTypesList\
    set imagesFolder to "Technomage:Users:andyhainline:Downloads:Images" as alias
    set appsFolder to "Technomage:Users:andyhainline:Downloads:Apps" as alias
    set archivesFolder to "Technomage:Users:andyhainline:Downloads:Archives" as alias
    set epubFolder to "Technomage:Users:andyhainline:Downloads:eBooks" as alias
    set fontsFolder to "Technomage:Users:andyhainline:Downloads:Fonts" as alias
    set docsFolder to "Technomage:Users:andyhainline:Downloads:PDFs and Docs" as alias
    set diskFolder to "Technomage:Users:andyhainline:Downloads:Installers and Disk Images" as alias
    set iconFolder to "Technomage:Users:andyhainline:Downloads:Icons" as alias
    set audioFolder to "Technomage:Users:andyhainline:Downloads:Audio" as alias
    set videoFolder to "Technomage:Users:andyhainline:Downloads:Video" as alias
    set otherFolder to "Technomage:Users:andyhainline:Downloads:Torrent Files" as alias
    set miscFolder to "Technomage:Users:andyhainline:Downloads:Miscellanious" as alias
    repeat with anItem in these_items
      set itemInfo to info of anItem
      if (kind of itemInfo) is in imageTypesList then
      move file itemInfo to imagesFolder
      else if (kind of itemInfo as text) is in audioTypesList then
      move file anItem to audioFolder with replacing
      else if (kind of itemInfo as text) is in videoTypesList then
      move file anItem to videoFolder with replacing
      else if (kind of itemInfo as text) is in fontTypesList then
      move file anItem to fontsFolder with replacing
      else if (kind of itemInfo as text) is in docsTypesList then
      move file anItem to docsFolder with replacing
      else if (kind of itemInfo as text) is in epubTypesList then
      move file anItem to epubFolder with replacing
      else if (kind of itemInfo as text) is in archTypesList then
      move file anItem to archivesFolder with replacing
      else if (kind of itemInfo as text) is in diskTypesList then
      move file anItem to diskFolder with replacing
      else if (kind of itemInfo as text) is in execTypesList then
      move file anItem to appsFolder with replacing
      else if (kind of itemInfo as text) is in webTypesList the
              move file anItem to docsFolder with replacing
      else if (kind of itemInfo as text) is in iconTypesList then
               move file anItem to iconFolder with replacing
      else if (kind of itemInfo as text) is in otherTypesList then
               move file anItem to otherFolder with replacing
      else if (kind of itemInfo as text) is not in uberList then
               move file anItem to msicFolder with replacing
      (*                              else if (kind of anItem as text) is "Folder" then
                                            set folderFiles to get every file of anItem
                                            processItems(folderFiles)
      end if
         end repeat
    end adding folder items to

    Well, I followed your instructions to letter, but the folder action still isn't triggering, or if it is, it isn't executing properly.  I can't figure out what's going on.  I tried executing the script directly from Script Debugger, but it just sits there, doing nothing (since it has no input, I would guess).  Any ideas on what's wrong?
    on adding folder items to this_folder after receiving these_items
         set imageTypesList to {"JPEG image", "Portable Network Graphics image", "Windows bitmap           image", "Graphics Interchange Format image", "Adobe Photoshop File", "TIFF Image"}
         set audioTypesList to {"MP3 audio", "AIFF-C audio", "Waveform audio"}
         set videoTypesList to {"Video-MPEG4", "MPEG-4 File", "Video-MPEG2", "Video-MPEG", "AVI", "Matroska           Video File"}
         set fontTypesList to {"TrueType font", "PostScript® Type 1 outline font", "Font Suitcase"}
         set docsTypesList to {"Portable Document Format (PDF)", "Scrivener Project", "Microsoft Word 97 - 2004           document", "Rich Text Document", "Plain Text Document", "CSV Document", "Pages Publication"}
         set epubTypesList to {"epub", "Kindle Document", "iBooks Author Template", "iBooks Author Book"}
         set archTypesList to {"ZIP archive", "tar archive", "rar archive", "Tar Gzip Archive"}
         set diskTypesList to {"Installer package", "Disk Image"}
         set execTypesList to {"Application (32-bit)", "Application", "Unix Executable File"}
         set webTypesList to {"HTML document", "XML document"}
         set iconTypesList to {"Apple Icon Image", "Icon Container", "Windows Icon Image"}
         set otherTypesList to {"XTorrent File"}
         set uberList to imageTypesList & audioTypesList & videoTypesList & fontTypesList ¬
                                  & docsTypesList & epubTypesList & archTypesList & diskTypesList & execTypesList ¬
                & webTypesList & iconTypesList & otherTypesList
    set imagesFolder to "Technomage:Users:andyhainline:Downloads:Images" as alias
    set appsFolder to "Technomage:Users:andyhainline:Downloads:Apps" as alias
    set archivesFolder to "Technomage:Users:andyhainline:Downloads:Archives" as alias
    set epubFolder to "Technomage:Users:andyhainline:Downloads:eBooks" as alias
    set fontsFolder to "Technomage:Users:andyhainline:Downloads:Fonts" as alias
    set docsFolder to "Technomage:Users:andyhainline:Downloads:PDFs and Docs" as alias
    set diskFolder to "Technomage:Users:andyhainline:Downloads:Installers and Disk Images" as alias
    set iconFolder to "Technomage:Users:andyhainline:Downloads:Icons" as alias
    set audioFolder to "Technomage:Users:andyhainline:Downloads:Audio" as alias
    set videoFolder to "Technomage:Users:andyhainline:Downloads:Video" as alias
    set otherFolder to "Technomage:Users:andyhainline:Downloads:Torrent Files" as alias
    set miscFolder to "Technomage:Users:andyhainline:Downloads:Miscellanious" as alias
    processItems(these_items)
    end adding folder items to
    on processItems(these_items)
         tell application "System Events"
              repeat with anItem in these_items
                   if (kind of anItem) is in imageTypesList then
                       move file anItem to imagesFolder
                  else if (kind of anItem) is in audioTypesList then
                       move file anItem to audioFolder with replacing
                 else if (kind of anItem) is in videoTypesList then
                       move file anItem to videoFolder with replacing
                 else if (kind of anItem) is in fontTypesList then
                      move file anItem to fontsFolder with replacing
                 else if (kind of anItem) is in docsTypesList then
                      move file anItem to docsFolder with replacing
                else if (kind of anItem) is in epubTypesList then
                      move file anItem to epubFolder with replacing
                else if (kind of anItem) is in archTypesList then
                      move file anItem to archivesFolder with replacing
                else if (kind of anItem) is in diskTypesList then
                     move file anItem to diskFolder with replacing
                else if (kind of anItem) is in execTypesList then
                     move file anItem to appsFolder with replacing
               else if (kind of anItem) is in webTypesList then
                    move file anItem to docsFolder with replacing
               else if (kind of anItem) is in iconTypesList then
                   move file anItem to iconFolder with replacing
               else if (kind of anItem) is in otherTypesList then
                   move file anItem to otherFolder with replacing
               else if (kind of anItem) is not in uberList then
                   move file anItem to msicFolder with replacing
               else if (kind of anItem as text) is "Folder" then
           set folderFiles to get every file of anItem
           processItems(folderFiles)
      end if
      end repeat
    end tell
    end processItems

  • 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.

  • Quality of JPEG when being converted by Folder Actions (Image Events)

    I take a lot screenshots with Command + Shift + 3/4. They are in PNG and I love them. Yet, I need to send them via email sometimes.
    I convert them to JPEG using Preview, but it is time-consuming when especially I have hundreds of them.
    I have just learnt that it is possible to do convert in batch using Folder Actions. However, I meet few very serious problems.
    1. In Preview, I could choose the quality of JPEG before converting. But, there is no such option in Folder Actions. I even searched online to try to modify the script and it seems that nobody cares about the quality of converted JPEG.
    My question: What is the quality of JPEG converted? And, is it possible to modify it?
    2. Since I do not know the quality of conversion using Folder Actions, I tried different qualities using Preview and match the outputs with those using Folder Actions. I got no result. As Preview is using Core Image as the processing architecture.
    My question: What is the image processing architecture adopted by Image Events?
    3. If the quality is unchangeable, can anyone teach me how to write a new script to do the conversion using Preview?
    I really hope Mac OS gurus could explain these to me and possibly solve my problems. I am interested to learn the AppleScript part to modify it.
    Thank you very much.

    It is the original folder action script from Mac OS. Here is the copy.
    Could you help me as well where to add the "compression level"? Also, what do "high", "low" and "medium" mean, in % just like Preview, if they use the same image processing architecture?
    Again, thank you very much for quick reply.
    ================
    Image - Duplicate as JPEG
    This Folder Action handler is triggered whenever items are added to the attached folder.
    The script creates a JPEG version of the file, but leaves a copy of the file
    in its original format. If the original file is already in JPEG format, the script does
    not duplicate the file.
    Copyright © 2002–2007 Apple Inc.
    You may incorporate this Apple sample code into your program(s) without
    restriction.  This Apple sample code has been provided "AS IS" and the
    responsibility for its operation is yours.  You are not permitted to
    redistribute this Apple sample code as "Apple sample code" after having
    made changes.  If you're going to redistribute the code, we require
    that you make it clear that the code was descended from Apple sample
    code, but that you've made changes.
    property done_foldername : "JPEG Images"
    property originals_foldername : "Original Images"
    property newimage_extension : "jpg"
    -- the list of file types which will be processed
    -- eg: {"PICT", "JPEG", "TIFF", "GIFf"}
    property type_list : {"TIFF", "GIFf", "PNGf", "PICT"}
    -- since file types are optional in Mac OS X,
    -- check the name extension if there is no file type
    -- NOTE: do not use periods (.) with the items in the name extensions list
    -- eg: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg", ".jpeg"}
    property extension_list : {"tif", "tiff", "gif", "png", "pict", "pct"}
    on adding folder items to this_folder after receiving these_items
              tell application "Finder"
                        if not (exists folder done_foldername of this_folder) then
      make new folder at this_folder with properties {name:done_foldername}
                        end if
                        set the results_folder to (folder done_foldername of this_folder) as alias
                        if not (exists folder originals_foldername of this_folder) then
      make new folder at this_folder with properties {name:originals_foldername}
                                  set current view of container window of this_folder to list view
                        end if
                        set the originals_folder to folder originals_foldername of this_folder
              end tell
              try
                        repeat with i from 1 to number of items in these_items
                                  set this_item to item i of these_items
                                  set the item_info to the info for this_item
                                  if (alias of the item_info is false and the file type of the item_info is in the type_list) or (the name extension of the item_info is in the extension_list) then
                                            tell application "Finder"
                                                      my resolve_conflicts(this_item, originals_folder, "")
                                                      set the new_name to my resolve_conflicts(this_item, results_folder, newimage_extension)
                                                      set the source_file to (move this_item to the originals_folder with replacing) as alias
                                            end tell
      process_item(source_file, new_name, results_folder)
                                  end if
                        end repeat
              on error error_message number error_number
                        if the error_number is not -128 then
                                  tell application "Finder"
      activate
      display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
                                  end tell
                        end if
              end try
    end adding folder items to
    on resolve_conflicts(this_item, target_folder, new_extension)
              tell application "Finder"
                        set the file_name to the name of this_item
                        set file_extension to the name extension of this_item
                        if the file_extension is "" then
                                  set the trimmed_name to the file_name
                        else
                                  set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
                        end if
                        if the new_extension is "" then
                                  set target_name to file_name
                                  set target_extension to file_extension
                        else
                                  set target_extension to new_extension
                                  set target_name to (the trimmed_name & "." & target_extension) as string
                        end if
                        if (exists document file target_name of target_folder) then
                                  set the name_increment to 1
                                  repeat
                                            set the new_name to (the trimmed_name & "." & (name_increment as string) & "." & target_extension) as string
                                            if not (exists document file new_name of the target_folder) then
      -- rename to conflicting file
                                                      set the name of document file target_name of the target_folder to the new_name
                                                      exit repeat
                                            else
                                                      set the name_increment to the name_increment + 1
                                            end if
                                  end repeat
                        end if
              end tell
              return the target_name
    end resolve_conflicts
    -- this sub-routine processes files
    on process_item(source_file, new_name, results_folder)
      -- NOTE that the variable this_item is a file reference in alias format
      -- FILE PROCESSING STATEMENTS GOES HERE
              try
      -- the target path is the destination folder and the new file name
                        set the target_path to ((results_folder as string) & new_name) as string
                        with timeout of 900 seconds
                                  tell application "Image Events"
      launch -- always use with Folder Actions
                                            set this_image to open file (source_file as string)
      save this_image as JPEG in file target_path with icon
      close this_image
                                  end tell
                        end timeout
              on error error_message
                        tell application "Finder"
      activate
      display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
                        end tell
              end try
    end process_item

  • 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.

  • 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

  • How to launch a folder action on save (rather than move)?

    Hello people. I'm working in Yosemite.
    I'm trying to create a folder action that keeps an up-to-date backup of MS word documents in a separate folder.
    Word for Mac does not allow me to save this backup in a separate folder. I have tried to create a folder action that simply moves any file with the word "Backup" in the title, and this works for files that are dragged into the folder, but not for files that are saved into the folder.
    Any suggestions on how to mover forward? I need a sort of "on save then apply filter" action.
    Thanks

    Record that action do not put a save in it. After you have that action saved with no documents open in photoshop use menu  File>Automate>Batch... in the batch dialog point to the action set and action, point source to your folder of images. In desternation use the pull-down menu and choose Save and Close.

Maybe you are looking for

  • Returns sale order stock from returns to quality error

    Dear All, For FG Material we have activated Inspection Type '06' - Returns from Customer Inspection and Inspection Plan with Usage 'Goods Issue 06' also created. We create return sale order material comes in returns and we need Inspection lot with '0

  • How do i set up iMessage on my Macbook Pro

    How do i set up iMessage on my macbook pro, all it shows is my apple id email address and i've tried 'Adding Email' as my number and it says an email has been sent although i do not recieve a text. I have no i dea how to set it up! Please help! <Pers

  • Oracle 10g installing on Oracle EL, getting ORA-12157 error?

    My boss is getting really impatient. I have tried installing Oracle 10g on... Oracle EL, CentOS 4, Fedora 4, Fedora 5, and I get the same error on them alll... ORA-12157: TNS: internal network communication error This occurs during the end phase of t

  • How to get screen Unmagnified.

    I hooked up my computer to the tv, and the screen never went back to normal. It's magnified, I can't figure out how to switch it back, can someone please help me?

  • Pricing procedure in RFQ

    I have copied pricing procedure & defined with Z. While maintaining RFQ, it is not adopting new pricing procedure... How to get new pricing procedure in RFQ doc