AppleScript: Set folder name of Folder Action?

Problem:
How to get the folder name that the running Folder Action script is attached too. Script is functional, stdin bash script with AppleScript via osascript. I just want the folder name, not the POSIX path to it. The System Events dictionary suggests this is possible. I don't want to hardcode the action's assigned folder in the bash script if I can get it dynamically from AppleScript. I know how to return it to bash. AppleScript newbie that has spent several hours googling and testing already.
Tried:
tell application "Finder"
     --AppleScript Editor can't get container -- no surprise. Folder action does work
     get POSIX path of (container of ((path to me) as text))
     set workingDir to quoted form of result
     display alert "Current Folder: " message workingDir as critical
end tell
tell application "System Events"
     activate
     --AppleScript Editor can't get name of folder action. Folder action does not work
     set currentDir to name of folder action
end tell
Appreciation for time and solution in advance.

twtwtw wrote:
In that case I suggest you make your life easier.  delete the osascript bit and just return a 0 or 1 from the shell script.  That integer will be passed on to the next action, so add an applescript action that checks to see if the input is 0 or 1 and displays a dialog if necessary:
on run {input, parameters}
          if input as integer > 0 then
  -- error
  display alert "whatever"
          end if
end run
The only reason I posted in the first place was to assess if it was possible to dynamically discover the folder name of the folder action using AppleScript through an osascript request. If the bash script has to be scrapped and entirely rewritten as a Applescript action -- just to obtain the folder name, then that answers my question.
The purpose of the osascript was to provide an OS X style, user friendly dialog that displays any martian files the bash script ignored. It was the least amount of coding for the result.
I believe that your input example from above would take the exit status from the preceding shell script. How is my invalidFiles variable passed then? In the shell script, I can pipe the invalidFiles printf line to pbcopy to put that content on the clipboard. After the script is done, I can retrieve that information with a pbpaste command. I wonder if this information is available to your trailing AppleScript action for inclusion in the display alert statement?

Similar Messages

  • Help Needed: Automator Applescript for Folder Action - Encode Video

    Hi !
    I have created an Automator Applescript for a Folder Action to do the following:
    When a new video file is moved to the target folder (i.e. Download of Vuze is done), automatically launch the Applescript Action that does the followin g(Applescripted):
    1) Using "run shell script" and FFMPEG on a UNIX command line, determine Width/Height, Framerate, Bitrate
    2) Calculate encoding parameters (slightly reduced bitrate, reduced Aspect etc.)
    3) Using "run shell script" with ffmpeg on the command line and the calculated parameters to encode the video file
    At the same time, the action is written to a log file so I know if a file is recognized, when encoding started etc.
    It works fine if I save this Action as an .app, make an alias on the Desktop and drop video files on it.
    It also works fine if I attach the script to a folder as a folder action and drag a video file in there.
    However, when I attach the script as a folder action to the Vuze download folder, it encodes only some video files, i.e. if there was a download of 5 files, chances are good that it will not encode 1 or 2 files out of those 5.
    If for example a second download finishes while the encoding for the first download is still going on, sometimes the second file starts encoding after the first encode finishes, sometimes it does not, the file does not make the log file at all, i.e. the folder action missed it or the automator action dropped it because it was still encoding. Still, sometimes it happens, sometimes not.
    As I need a solution that is 100% accurate, I would like to ask if there are any ideas on how to do this better maybe? As I am not an Applescript Guru, I would need some help to know what works and what doesn't and what the syntax is.
    My main idea right now:
    Similar to how ffmpegX works with its "process" application, have a second script (as .app) that receives the files to be encoded from the automator action and puts them in a queue, then proceeds to encode this queue while the main automator action is free to receive the next file.
    Writing this second app is quite straightforward (a modified version of my current script) but I have some questions I need help with:
    1) How do I call another applescript from within an existing applescript that launches the new applescript in a new process?
    2) How do I pass parameters to this new applescript?
    3) In case of this "Queueing" Idea, once I called the external applescript the first time, how do I make sure when I call next time, that I don't open a second instance of this script but rather pass another queue item to the original instance to be processed?
    Or in general: Is there a better way to achieve this automatic encoding solution that I have not thought about?
    Alternatively:
    Does anyone know how to call the "process" application that comes with the ffmpegX package with the correct parameters to use as a queueing / processing tool?
    Thanks!
    Joe
    Message was edited by: Joe15000
    Message was edited by: Joe15000

    To do this, I created an Automator workflow with an Applescript snippet to change the 'media kind'.
    Here is the 'Run Applescript' workflow step code:
    on run {input, parameters}
              tell application "iTunes"
                        set video kind of (item 1 of input) to movie
              end tell
              return input
    end run
    Prior to this running, I have an 'Import Files into iTunes' workflow step.
    You can switch out 'movie' with: 'TV show', 'music video', or anything in ITLibMediaItemMediaKind.
    Good luck,
    Glenn

  • 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

  • Folder Action Problems with Leopard 10.5.8

    My company recently upgraded from 10.4.11 to 10.5.8 and our folder actions have been stopping mid-process or not working at all. Sometimes a few files will process and then everything stops completely.
    Our workflow involves the use of several different hot folders that use folder actions (converting InDesign CS4 documents to various quality of PDFs). All of the actions are single stream, meaning each folder does the action it's assigned and the original file is trashed and the new file remains in the folder. There are no subsequent folder actions that pull from the newly processed files. We also only run one folder action (with several files dropped in it) at a time.
    I have also tried running a pre-made generic folder action script from Apple and it, too will stop mid-process, process a few files then stop, or not work at all.
    Does anyone know what might be causing this problem with either the new Applescript or Folder Actions with Leopard 10.5.8?

    I have several scripts that all work different ways. One script I have opens the InDesign document, exports a PDF to a different folder located elsewhere on the hard drive (where a different script searches for PDFs). After this the original document is sent to the trash. Nothing new is created in the original Folder Action Scripted folder.
    What's more, even Apple's stock Folder Actions don't work properly and stop mid-process. I've seen vague reports of 10.5.8 having issues with Applescript or Leopard in general. The fact this script works perfectly in 10.4.11 makes me think that something has changed with the way Leopard handles the FA's.

  • Set file name as a variable. Then use it to name a folder

    I'm making a workflow that I want to get the selected file, then create a new folder using that file's name. I made a workflow as follows:
    Get selected Finder Item (In this case a JPG image)
    Set Value of Variable
    New Folder (dragging the variable from 'Set Value of Variable')
    But running this workflow it adds the path of the file to the new folders name, as well as the file's name (e.g. instead of the folder being called 'Photo1' it's called '/Users/Jono/Desktop/Photo1.jpg').
    Does anybody know how I could get it to just the file name (preferably without the extension) instead of prefixing it with the path?

    The New Folder action uses the specified text for the file name. The following Run AppleScript action will return just the names of the Finder Items passed to it:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters}
    get a name from a file path
    input: a list of Finder Items (aliases)
    output: a list of names
    set output to {}
    repeat with AnItem in the input -- step through each item in the input
    set {name:TheName, name extension:TheExtension} to (info for AnItem)
    if TheExtension is missing value then set TheExtension to ""
    set end of output to (text 1 thru -((count TheExtension) + 2) of TheName) -- just the name part
    end repeat
    return the output -- pass the result(s) to the next action
    end run
    </pre>

  • AppleScript Folder Actions

    I'm new to this group, and my question may have been answered a long time ago as I'm using OS 10.5.8. I've been teaching myself AppleScript, and have been using "AppleScript - The Missing Manual" by Adam Goldstein and "AppleScript 1-2-3" by Sal Soghoian and Bill Cheeseman. All has gone well until now. I'm working on a couple of folder actions and have hit a wall. I've successfully written "on opening..." and "on closing..." actions. However, I have been 100% UNsuccessful at writing "on adding folder items to..." scripts. Action scripts are saved in the proper location, are attached properly, and folder actions are enabled. I turned a primary "on adding..." script (one I started out to do) into a droplet, and it functions perfectly when files are dropped on it. Help in explaining to me "the error of my ways" would be appreciated.

    If there is an error in a folder action script, it tends to fail silently - for example, your *opening folder* script will fail because you are not coercing theCount (a number) to text (display dialog doesn't like lists, which is what you are getting by concatenating a string to a number).
    Since you have a droplet that works correctly, you can just add a folder action handler to that script. I use a folder action template that includes handlers so that it can be run and tested from the *Script Editor* (it can also be used as a droplet). In the following example, the doStuff handler is what does the stuff, and the other handlers (including the folder action) just pass items to it.
    <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: #FFD891;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run -- application double-clicked or run from the Script Editor
    tell application "Finder" to try
    set someItems to (the selection) as alias list
    on error errorMessage number errorNumber
    set someItems to (the selection) as alias as list
    end try
    if someItems is {} then set someItems to (choose file with multiple selections allowed)
    doStuff for someItems
    return
    end run
    on open theFiles -- items dropped onto the application
    doStuff for theFiles
    return
    end open
    on adding folder items to this_folder after receiving these_items
    handle items added to a folder
    parameters - this_folder [alias]: the folder added to
    these_items [list]: a list of items (aliases) added
    returns nothing
    doStuff for these_items
    return
    end adding folder items to
    to doStuff for someFiles
    do stuff with each file in someFiles
    parameters - someFiles [list]: a list of files to do stuff with
    returns nothing
    repeat with anItem in someFiles
    try
    -- do stuff, for example:
    tell application "Finder"
    set theName to name of anItem
    considering case -- case sensitive match
    if "-P" is in theName then
    move anItem to alias "HD:Users:myself:Property:All Property"
    else if "-GP" is in theName then
    move anItem to alias "HD:Users:myself:Photography:General Photos"
    else
    log "no match"
    end if
    end considering
    end tell
    on error errorMessage number errorNumber -- oops
    log errorMessage
    -- activate me
    -- display alert "Error " & errorNumber message errorMessage
    end try
    end repeat
    return
    end doStuff
    </pre>

  • Automator Folder Action: File Name = Spotlight Comment?

    Hey guys,
    I'm trying to have automator add the original filename of a file as spotlight comment when it is added to a certain folder. I can only use the "Set Spotlight Comments for Finder Items" in folder actions to add a specified comment, but nothing else. Is it possible to grab the file name via applescript?
    The idea behind this is to preserve the original file names of all downloaded files before they get renamed.
    Thanks,
    V

    Thanks for your reply, I now have your action installed and it does get the filenames, but I still can't add them to the spotlight comment text box. Looks like I didn't think this through properly.

  • Processing a File (From a Folder Action) Through an AppleScript

    I have a Folder Action enabled which automatically uploads images placed in a folder to a FTP server. It works great when I'm at home on my own network, but if I'm somewhere with a firewall that prohibits connecting to my FTP server (i.e. work) or if I am not connected to the internet, the folder action will still run but my images will never get uploaded.
    I've attached a screenshot of my workflow. The folder action gets the image added to the folder, copies the original to a different folder, and then scales the image down to a smaller size before uploading it. I'm using the upload workflow action from Transmit.
    I figured I could use an AppleScript to check whether or not my computer can reach the ftp server and then wait until it was connected to run the rest of the workflow if it can't reach the server:
    repeat with i from 1 to 86400
        try
            do shell script "ping -o ftp.examplewebsite.com"
            exit repeat
        on error
            delay 5
            if i = 86400 then error number -128
        end try
    end repeat
    The only problem is, I'm pretty inexperienced with AppleScript and am not really sure how or where to insert it into my workflow to get the image to "pass through" the AppleScript. Currently, whenever I include this AppleScript in my workflow, before the Upload action, for example, the image ends up not getting passed through the AppleScript and it doesn't get uploaded as a result.
    Hopefully this a fairly simple question and someone can help me out, or if there's an easier way to delay running a folder action until I can connect to the server someone will let me know. I can clarify anything if necessary.

    Good job
    I just saw this…
    applescript in automator - stop a workflow
    It kills the workflow based on a test, so I tried this…
    Here is the text if you want to copy & paste. It will fail on Apple.com & stop the workflow. Success should allow it to continue.
    on run {input, parameters}
      try
      set pinged to do shell script "ping -c 3 -q  apple.com "
      if pinged is equal to 0 then
      return input
      end if
      on error
      error number -128 -- exit by user-cancel
      end try
    end run
    on run {input, parameters}
       display dialog "Rest of script will now continue..."
      return input
    end run

  • Applescript to change file type using folder action

    Just found out my Adobe Acrobat is saving PDFs with the filetype "FDP" and creator "ORAC" which is obviously the reverse of what they should be.
    There doesn't appear to be a fix for this, and for me it's a problem because when I copy these PDFs onto our Xinet WebNative asset management server the files aren't recognised as PDFs, so don't display a preview in the web page.
    So, I wanted to use a folder action that will set the Creator and Type to the PDFs whenever they are put into a folder on the server.
    Unfurtunately, although I can get this to work when using a script in the form of an application (so I drop PDFs onto it, I cannot get it to work as a folder action. It doesn't set the creator and type even though the same commands in a application script do work.
    *This is the code to my script which works fine as an application:*
    ====================
    property FileType : ""
    property CreatorType : ""
    on open theFiles
    tell application "Finder"
    activate
    set FileType to "PDF "
    set CreatorType to "CARO"
    repeat with eachFile in theFiles
    set the file type of eachFile to FileType
    set the creator type of eachFile to CreatorType
    end repeat
    end tell
    end open
    ===================
    *and this is what I'm trying to use for a folder action:*
    ===================
    on adding folder items to my_folder after receiving the_files
    set pdfs to {"pdf"}
    repeat with i from 1 to number of items in the_files
    tell application "Finder"
    set this_file to (item i of the_files)
    set the file_path to the quoted form of the POSIX path of this_file
    --set the file_path2 to the quoted form of file_path --can combine if file_path isn't needed
    set this_fileType to name extension of (info for this_file)
    end tell
    if this_fileType is in pdfs then
    tell application "Finder"
    activate
    set FileType to "PDF "
    set CreatorType to "CARO"
    end tell
    end if
    end repeat
    end adding folder items to
    ==================
    I know it processes the file but it doesn't actually change the creator type.
    *If only Apple would fix this bug in the first place!*

    Your folder action script isn't using the same commands, and doesn't do anything about setting file types or creator codes at all. Something like this should do the trick:
    <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: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on adding folder items to my_folder after receiving the_files
    set pdfs to {"pdf"}
    repeat with each_file in the_files
    set this_fileType to name extension of (info for each_file)
    if this_fileType is in pdfs then
    tell application "Finder"
    set file type of each_file to "PDF "
    set creator type of each_file to "CARO"
    end tell
    end if
    end repeat
    end adding folder items to
    </pre>
    ... and by the way, Apple doesn't have anything to do with the file types, creator codes, or other application specific settings that an Adobe application sets for itself.

  • Quicktime export using applescript/folder actions

    I have about 500Gig of encoded H264 footage.
    I want to be able to "bulk" change video properties on all of the video so that when I view it in front row it isn't letter boxed.
    I can do this manually, save as a .MOV and all is fine.
    anyone tried something like this as an applescript?
    I have scripted eyetv quite a bit so I`m quite familiar with applescript, just being lazy I suppose!
    any help greatly received !
    * looking in the quicktime applescript library *
    Steve

    The nature of your question implies that you're unfamiliar with Folder Actions...
    I'd like to skip them or write the AppleScript in a way that handles this.
    By their very nature, Folder Actions are passed a list of newly-added files. Your Folder Action script should look something like:
    on adding folder items to my_folder after receiving the_files
      -- your code goes here
    end adding folder items to
    where, in this case, the_files is a list of the newly-added files. It won't include pre-existing files, so all you need to do is iterate through the_files and you're set. Something like:
    on adding folder items to my_folder after receiving the_files
              tell application "iPhoto"
                        repeat with each_photo in the_files
                                  try
                                            import each_photo to album "Europe 2012"
                                  end try
                        end repeat
              end tell
    end adding folder items to
    The only caveat here that I can think of is the fact it's a DropBox folder, so there might be some odd latency in the files appearing in the directory, but I don't use Dropbox to know.
    Note that in the above I import each photo independently, via a repeat loop. This might not be necessary, and you might be able to pass the entire the_files variable to the import command to have all the images imported in one go - I haven't tried that, though.

  • Set Folder Name From File Name Inclosed.

    Hello scripters,
    There has been quite a few topics about setting file names from parent folders. I believe it's possible but not sure how to reverse this process. That is to say set the folder name from a file in the folder. This is what I'm imagining.
    I've got a folder. In the folder are 100 folders with the names "untitled folder xxx" In side I've got files that are all named and numbered.
    For example,
    untitled folder/B-day 001~050.jpg
    untitled folder 50/At The Park 001~020.jpg
    I would like a script to change the name of the parent folder of the files that it houses.
    So untitled folder becomes
    B-Day
    untitled folder 50 becomes
    At The Park
    etc…
    I think getting the name of the first file (minus the index number) would be easiest.
    Any help or futher questions are greatly appreciated.
    Maximilian

    Working backwards...
    Assuming all the files have the same name structure (e.g. end in the format "xxx~xxx.jpg" you can get the base name using:
    <pre class=command>set baseName to characters 1 through -13 of filename as text</pre>
    This cuts off the last 12 characters of the file name.
    Once you have a folder, you can get the names of files in the folder via the Finder. for sanity's sake I'd ask the Finder for the first item, just in case there's more than one file:
    <pre class=command>set filname to name of first item of (files of folder theFolder)</pre>
    And if all the folders are in one top folder, you can iterate through them like:
    <pre class=command>repeat with eachFolder in (every folder of folder topFolder)</pre>
    So now, string it all together:
    <pre class=command>tell application "Finder" -- we'll use the Finder to do the legwork
    set topFolder to (choose folder with prompt "Choose the top level folder" ) -- get the top folder
    repeat with eachFolder in (every folder of folder topFolder)
    set fileName to name of first file of (files of folder topFolder)
    set baseName to characters 1 through -13 of fileName as text
    set name of folder eachFolder to baseName
    end repeat
    end tell</pre>
    Note there's no error checking - the script will fail if there are no files in any particular folder, but it should get you going.

  • Need a Folder Action Script to automate running of Applescripts in iTunes

    I posted this in the OSX forum but thought i'd try here too:
    I have a couple of applescripts that I have begun using on some of my podcasts. Specifically they will deselect "Skip When Shuffling" and "Remember Track Position" (Thanks Doug!). I feel like it is getting tedious to have to remember to run these scripts every time the Podcast updates a new episode. I'm looking for a folder action script that will run these applescripts whenever a new item is added to their folder. While I try to puzzle one together (having never written one) does anyone have anything to fit these needs?

    Yes.
    I recently need one to do something else.
    I'll just give you the script I am using, you can hack at will...
    property TargetPlaylist : "Library"
    on adding folder items to this_folder after receiving added_items
    repeat with each_item in added_items
    tell application "iTunes"
    add each_item to playlist TargetPlaylist
    end tell
    end repeat
    tell application "Finder"
    move every item of this_folder to the trash
    empty the trash
    end tell
    end adding folder items to
    This script when attached as a folder action will add the items dropped into it to my iTunes library, then delete them.
    You can easily tear this one apart to get what you need done.
    Beavis2084

  • Folder action to package and create pdf Applescript folder action

    Hi
    Does anyone have an Applescript Folder Action to package Indesign CS5.5 files and make pdfs.
    Thanks, in advance.

    Hi Babs
    I ended up paying someone to create the script. They did a fantastic job creating a droplet that has options to package, create PDFs to presets, print to presets, create an IDML file, retrosave this to CS4 and create a thumbnail. Sounds like a lot but that is what I ended up needing for one client and I can use it on anything.
    Thanks
    Mac
    Sent from my iPhone

  • AppleScript: how to reinstall "Folder Actions Setup"

    MacBook Air with Yosemite 10.10.3
    Although I can successfully use Script Editor and get AppleScripts to run, the /Applications/AppleScript folder is missing:
    Erins-MacBook-Air:~ Peter$ ls -l /Applications/App*
    /Applications/App Store.app:
    total 0
    drwxr-xr-x  9 root  wheel  306 Apr 11 14:53 Contents
    /Applications/Application Loader.app:
    total 0
    drwxrwxr-x  11 root  admin  374 Sep 16  2014 Contents
    Erins-MacBook-Air:~ Peter$
    I need to run the "Folder Actions Setup" app which is normally in the AppleScript folder.  I have reason to believe it was deleted in an attempt to recover disk space.
    In the app store, I tried to "upgrade" to Yosemite, and I got a message that since I already have Yosemite, I could simply use the "update" feature, but the entire upgrade installer is available if I really wanted to download it. I did that, and I ran through the entire process, which did some things, including changing my desktop image back to the default.  However, I still aint got no AppleScript folder.
    What next?

    Thanks.
    It would be nice if this weren't obsolete:
    https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/App leScriptLangGuide/reference/ASLR_folder_…
    I'm still learning my way around Folder Actions, but it seems that the GUI "setup" item is pretty minimal.
    If I successfully write a handler script for "on adding items to a folder...", and put it in the right place, apparently I can get everything working by ctrl-clicking the target folder in the Finder, and using the Services context menu to associate the target folder with the script I'm writing.
    This will be a bit obtuse for some people.  Perhaps Hazel fills this need better. 
    But thanks for the info!

Maybe you are looking for

  • How can I create subfolders in Mac Mail for an Exchange account?

    I use Mac Mail on OS X 10.8.4 to download my Exchange mail, which is hosted on Office 365. I can create folders inside existing subfolders in my Inbox, but if I try to create one as a first-level subfolder of the Inbox the option does not exist. Inst

  • Loading assemblies using Reflection when dependant dlls are missing.

    Hello All, I've created a sample WinForms application where I upload a dll (present in my local machine). I just need to read the public types (classes) defined in the assembly. So I've used the ExportedTypes property. When the dependant dlls are pre

  • How do I create a One to many relationship page in Dreamweaver?

    How do I create a page in dreamweaver that comes up after the user logs in from the log in page that will allow the user to: Add, change and delete in 2 tables that are in my MYSQL database that is a one to many relationship One thing that is confusi

  • Installing Photoshop Elements in a computer lab?

    Hey there! I am trying to install Photoshop Elements 12 in a computer lab. We have 33 computers that we would like to have Photoshop Elements 12 installed on. We have licenses for them but the concern is the whole Adobe ID setup. This is a high schoo

  • Process Class:How to give and get data from an exe file continuously???

    hi,,, I am trying to run an executable file from my program to give it input and read its output.... And i am having problems... The exe file takes one input and appends to it "1235" (ITS A TEST CASE). When it is only for a single input , the program