Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator - Moving files to a newly created folder

Hello,


I'm very new to automator (and even newer to apple script). I am trying to set up a folder action to do the following... When a file is added to the "images" folder a new dated subfolder would automatically be created, and the file would be moved to this new dated subfolder.


Here's what I have so far (which I'm sure is way off base)


1) Folder action receives files and folders added to "Images"

2) Filter finder items - Find files where ALL of the following is true: Kind is ANY

3) New Folder - Name is "_" Where: "Images"

4) Add Date or Time to Finder Item Names: Add Date to folder name

5) Move Finder Items: This is the step that I'm stuck on. I don't know how indicate the newly created folder in step 3


Another question I have is how to make automator check to see if there's already a subfolder with the current date and put the file in that subfolder instead of creating a new subfolder with a duplicate name.


Any help would be appreciated!


Thanks,

K

MacBook Pro (15-inch Late 2008), Mac OS X (10.6.8)

Posted on May 18, 2012 2:14 PM

Reply
6 replies

May 18, 2012 3:07 PM in response to kallain

If you don't want to copy the input items then you will need to put them into a variable that you can use later. However, your main problem will be creating the new folder in the attached folder - adding a new folder will trigger the folder action again, most likely interrupting the original workflow. You will need to use a separate folder (it can already exist inside the attached folder) that doesn't have a folder action attached to it.


  1. Folder Action ...
  2. Filter Finder Items ...
  3. Set Value of Variable { Variable: Original Items }
  4. New Folder { Name: drag Today's date variable here, formatting as desired
    Where: somewhere other than the attached folder }
    (Ignore Input)
  5. Set Value of Variable { Variable: My Folder }
  6. Get Value of Variable { Variable: Original Items } (Ignore Input)
  7. Move Finder Items { To: drag My Folder variable here }


The New Folder action won't give you an error if the folder already exists - it will return a path to the folder either way.

May 19, 2012 11:38 AM in response to red_menace

Thank you for your help Red_Menace,


I set up my folder action just as you suggested to no avail. I have discovered through trial and error that my "Move Finder Items" command is not working. I even wrote a script (which I found on another forum discussion) to move items from one folder to another and it still doesn't work. Attached are the frame grabs from the folder action you suggested in case you can see anything I missed.User uploaded fileUser uploaded file


Here is a copy of the script that isn't working as well:


on adding folder items tothis_folderafter receivingadded_items

tell application "Finder"

repeat with this_item in added_items

move this_item to folder "_" of folder "Test" of folder "Desktop" of folder "krista" of folder "Users" of startup disk

end repeat

end tell

end adding folder items to


Thanks again,

K

May 19, 2012 1:39 PM in response to kallain

It is almost identical to my test workflow (I set the new folder name directly by using the Today's date variable), which works on my machines (tested in both Lion and Snow Leopard). You mention that the Move action seems to be the problem - can you be more specific than "it isn't working" (you can look at the action results to see what items are being passed)? Will the workflow run from Automator (you will need to add an action to get some input)? Are folder actions enabled and is the workflow actually attached to the folder?

Jan 31, 2014 4:15 AM in response to kallain

Hello Kallain,


I presumed you already know the solution of this issue but for others to reference this problem, here's the best solution.


Why it gets an error message?


If you see the logs the error says "YourFolder can't be moved to "YourFolder"

Logically automator was confused, he thinks you wanted to move the same folder to the same location.


Now to avoid that... you must add one action, "Get folder contents" under "Get value of variable" and it will solve the problem!


Good luck!

Ernesto

Jan 31, 2014 10:26 AM in response to ebmontejo

May bad Kallain! because I have tested out my tip and it just COPIED it instead of moving the files. So after quite a trial and error on my side, I have finally mastered it!


In my case I am moving multiple files thru 3 label ordering (2 new locations(folder) and 1 existing folder) then after the transfer it unlabeled the files automatically... Here's the automator action:


Step 1. Variable A to new folder

1. Open workflow documentation

2. Create New folder

3. set variable (variable: create A)

4. find finder items {label}

5. get folder contents (this is the important action)

6. label finder items (don't click any color)

7. move finder items (where: your A variable)


Step 2. Variable B to new folder

8-13. repeat step 2-7 with different variables

- most important difference is, in the create new folder(step 8), you must click "ignore this actions input" to avoid transferring all files to all folders


Step 3 Files to existing folder

14. drag "Ask to text" action( just add any text and don't tick required answer!) - Since you don't have a variable

15-17. just follow steps 4-6 or 11-13

19. move finder items (where: folder location)


That's all! Please share this new automator tip! I barely see any discussion about this. As it is easy to just copy files to a new folder rather than moving it!


Thanks,

Ernesto

Store Administrator

Organics Superfoods Store

Automator - Moving files to a newly created folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.