Problem moving files using applescript/folder action setup.

I'm wanting files to move to certain folders depending on what the first letter of the file name. Here is what I have so far. If the file starts with TF715SH it should move to Serenity:Color Images for Monthly:T
property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
on adding folder items to this_folder after receiving added_items
    try
        tell application "Finder"
            repeat with this_item in added_items
                if this_item starts with "M" then
                    move this_item to "Serenity:Color Images for Monthly:M:" with replacing
                end if
                if this_item starts with "N" then
                    move this_item to "Serenity:Color Images for Monthly:N:" with replacing
                end if
                if this_item starts with "T" then
                    move this_item to "Serenity:Color Images for Monthly:T:" with replacing
                end if
            end repeat
        end tell
    end try
end adding folder items to

Hi,
Because the class of this_item is a alias wich contains the full path of the file :
You need to get the file name, also you must use the term "folder" before the string "Serenity:Color Images for Monthly:M:", otherwise the Finder will return an error.
if (name of this_item) starts with "M" then
      move this_item to folder "Serenity:Color Images for Monthly:M:" with replacing
end if
Here's another way to do this :
on adding folder items to this_folder after receiving added_items
      tell application "Finder"
            set colorImgFolder to folder "Serenity:Color Images for Monthly:"
            repeat with this_item in added_items
                  set c to first character of (get name of this_item)
                  considering case -- case sensitive
                        if c is in "MNT" then move this_item to folder c of colorImgFolder with replacing
                  end considering
            end repeat
      end tell
end adding folder items to

Similar Messages

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

  • Applescript - Folder Actions Setup

    trying to make a folder action to move anything dropped in a folder to shared folder on another device.  code as follows:
    set destFolder to (":" & (path to desktop as string) & "Workflows:Sheetfed:")
    display dialog destFolder
    on adding folder items to this_folder after receiving added_items
              try
                        tell application "Finder"
      move added_items to destFolder
                        end tell
              end try
    end adding folder items to
    Nothing happens.
    Note:  I added the display to see the path when I was hand running.
    Do I need to use posix path for this, or maybe use command line??  Not sure what's best - easiest - most reliable
    Any assistance is greatly appreciated.

    Thank you.
    I have this:
    set destFolder to (":dx1070:Workflows:Sheetfed:")
    on adding folder items to this_folder after receiving added_items
              try
                        tell application "Finder"
      move added_items to folder destFolder
                        end tell
              end try
    end adding folder items to
    But still not doing it yet.
    Took off the leading colon on destFolder ie ":dx1070:Workflows:Sheetfed:", still no.
    Any more help would be great!

  • I am having a problem moving files from a iMac  in location mac in another location.  I have tried using Dropbox and the Public folder in the i disc.  When I drag the files into dropbox they become alias' and I can't open them at the other end beca

    I am having a problem moving files from an imac in one location to an imac inanother location.  I have tried using Dropbox which is installed in both locations but when i drad a file ino yhe app it becomes an alias.  When I get to the other location it says I can't open the file because the " original application that created it is not present".  This is despite the fact that the app that created both files is installed in both computers.  If I use the Public folder in the idisc, when I get to the other location the file isn't there.  Am I forgetting to turn something on or off?  Should I manually sync the Public folder and if so how? Thanks
    Message was edited by: stephenfromdelray beach

    So now that's two of us.  Hopefully, someone has an answer. 

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

  • Suddenly I have problems moving files to the trash...  get a dialog saying Finder wants to make changes and I must provide the password... Any explanation or ideas how I can get this to stop?

    Suddenly I have problems moving files to the trash...  get a dialog saying Finder wants to make changes and I must provide the password... Any explanation or ideas how I can get this to stop?

    Please take these steps if you're prompted for a password when moving items in your home folder to the Trash.
    1. Triple-click anywhere in the line below on this page to select it:
    ~/.Trash
    2. Right-click or control-click the highlighted line and select
    Services ▹ Show Info
    from the contextual menu.* An Info dialog should open.
    3. The dialog should show "You can read and write" in the Sharing & Permissions section. If that's not what it shows, click the padlock icon in the lower right corner of the window and enter your password when prompted. Use the plus- and minus-sign buttons to give yourself Read & Write access and "everyone" No Access. Delete any other entries in the access list.
    4. In the General section, uncheck the box marked Locked if it's checked.
    5. From the action menu (gear icon) at the bottom of the dialog, select Apply to enclosed items and confirm.
    6. Close the Info window and test.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. Open a TextEdit window and paste into it (command-V). Select the line you just pasted and continue as above.

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

  • Folder Actions Setup- connection failed

    Every time I open Folder Actions Setup I get an error message saying "Connection Failed- Server may no longer exist..." and "Automatically Add to iTunes" is in red. I click ok and it keeps popping up. I've removed that server from my favorites since it no longer exists. It was a MBWE Blue Rings that I had connected to my AEBS. It had my iTunes library on it , but has since been transferred to an external drive connected directly to my MP.
    How do I make it stop? I can't assign any Folder Actions to any folders until this stops!

    Here is the console message:
    5/31/11 11:26:55 AM          Automator[335]          Can not ID UTI for path /Volumes/PUBLIC/Automatically Add to iTunes: The file “Automatically Add to iTunes” couldn’t be opened because there is no such file.

  • Folder Actions Setup

    how can I get to this function?
    Please read...
    posted by  Frank Caggiano
    this should improve performance...
    Right click on the file and select Services from the menu then Folder Actions Setup
    This will open
    Check to see which (if any) folders have actions. If you didn;t turn it on intntionally disable it.

    Hi deltone,
    Although your product information says, "iMac 27", Mac OS X (10.6.8), 2.7 GHz Intel Core i5, 4GB 1333MHz", I'm guessing you are beyond that.   
    Here's why, folder actions have changed places.  Check out this help from others (thanks to Barney-15E, VikingOSX and ChangeAgent).
    Attaching folder action scripts not available i... | Apple Support Communities
    Best Regards,
    Nubz

  • Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Yes, but that would not cause the "build  failed" message.
    right I missed that part. Looks like two problems then.
    //  main.m
    //  ASCTestFopen
    //  Created by Frank Caggiano on 3/2/13.
    //  Copyright (c) 2013 Frank Caggiano. All rights reserved.
    #import <Foundation/Foundation.h>
    #include <stdio.h> 
    int main(int argc, const char * argv[])
        @autoreleasepool {
            FILE *fp, *fopen();
            // insert code here...
            if((fp = fopen("~/test.txt","r")) == NULL)
                NSLog(@"open failed");
        return 0;
    This will compile ad run in Xcode with a project type of comand line tool

  • Folder Actions Setup Missing?

    I'm running Mavericks 10.9.3, and would like to setup some folder actions . I've not done this for some time, but when I went to the Finder, then right-clicked on a folder, no Folder Actions Setup; in fact, doesn't exist anywhere. Maybe there is something else to be installed?

    Didn't know that.
    (I needed to activate it in:
      ->System Preferences->Keyboard->[Shortcuts]->[Services])

  • 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

  • Using Automator Folder Actions

    I have an automator folder action that runs to take any pdf file dumped in to the folder, send to the printer and then delete it.
    How do I make this run on a server that I'm not logged in to (effectively as a service), so that if a pdf file is generated somewhere on the network (maybe even a PHP script on a web site hosted on this server) and copied to this folder it still auto prints to the network printer?

    I'm using a hot folder to import to Aperture as well, and also had the same problems when I try to configure it.
    I solve it by creating an action in Automator that will copy all the images from the memory card to a temp folder when a card is inserted in the card reader. At the end of the action all the files inside the temp folder are moved to the actual hot folder, as you said this is almost instant so works perfectly.
    So basicly the workaround is the following:
    Card inserted - Image capture starts and copy all the images to a temp folder - Images then move to Aperture's hot folder - Aperture gets all the images.

  • Problems moving files around in finder

    Does anyone else have the same problem I do when moving files around in finder. It almost always says you do not have sufficient access privileges and each time I have to go to the destination folder info box and change access permissions. It is now getting really annoying. At work I can not copy files off my laptop to the network as again it says I do not have permission though if I log on from a machine using tiger I can move the files easily. Moving files to my Lacie drive causes the same problem. If anyone out there has and easy fix or explanation I would be grateful

    I decided to go the long way and move everything where I wanted it to be.  I moved everything around in Bridge, I then synchronized the folder to reflect how it should.  So far so good!
    Thank you all for your help and interest, I really appreciate everything!
    I do have one more question now, I will also start a new thread to see what else I can get, but again thank you!
    I have syncroniced the folder after making the changes, and due to the problem I was having last time I did it again just to double check.  It said there were over2k photos missing so I clicked sync, let it do its thing.  And just to tripple check I ran it again and it is saying the same thing, missing over 2k photos.  What does this mean?

Maybe you are looking for

  • ResultSet merge

    Does anyone know if there is a way of creating one result set from two? I need to write a query to return results from two databases that can not talk to each other (!). The results are only seen after some java fantasticness has turned them into an

  • How to get the selected item of a ListBox if it's contents are binded data? (Please read)

    So, I am making an application in which binds data from a WebClient to a ListBox. Thus, it is needed to understand that I did not create this data, it is from a Web API. So my goal is to be able to click on any of the items in the list box(which are

  • With the function "getEnhancedMicrophone",play will go wrong?

    I want to write a program can pull the rtmp stream from FMS or push to FMS,something like video conference system. At first,the program play normally. But when I use the function "getEnhancedMicrophone" to get a microphone,it will go wrong. The voice

  • Exporting Long Projects to AAC Files with Chapters

    Hey Is it possible to export an AAC file with chapters at around two hours in length? I get the "maximum file size of 2gb exceeded" if I try from Garage band (even though the wav the project is made from is made from is only 1.2Gb and the estimated A

  • Retrieving accidentally deleted photos

    Is there any way to recover accidentally deleted photos from the iphone? I was on vacation so I had not backed up any new pics. Thanks!