Copying Finder items into same folder as Action

I want an Action that can copy Finder items directly into the same folder the Action resides in, i.e. without specifying where or asking the user where.

Is this possible? All I've been able to create so far is an Action whereby I need to specify the folder or get the user to specify it.

Mac OS X (10.5.4), Mac OS X 10.5.4 Server Standard Setup

Posted on Sep 1, 2008 8:10 AM

Reply
9 replies

Sep 1, 2008 9:29 AM in response to Christiaan

if I understand you correctly you want to be able to select a folder in finder, then run the workflow and copy some items (which ones then?) to that fodler. is this right? that can be easily done using variables. a a new variable to your workflow. the flow should be like this

1. get selected finder items
2. set value of variable
here you set the value of that variable to the selected item
...your flow
copy finder items. here drag the variable to the field where you set where you are copying things to.

Sep 1, 2008 9:54 AM in response to Christiaan

If the workflow has been saved as an application, you can also use a Run AppleScript action to get the path of the container it is in. The following action returns the location of your Automator application - you can then put it into a variable, or whatever:

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

tell application "Finder"
get the container of (path to me)
return the result as alias
end tell

end run</pre>

Note that if the workflow has not been saved as an application, the path returned will be the container where the Automator.app is located (usually /Applications).

Sep 2, 2008 1:18 AM in response to V.K.

V.K. wrote:
if I understand you correctly you want to be able to select a folder in finder, then run the workflow and copy some items (which ones then?) to that fodler. is this right? that can be easily done using variables. a a new variable to your workflow. the flow should be like this

1. get selected finder items
2. set value of variable
here you set the value of that variable to the selected item
...your flow
copy finder items. here drag the variable to the field where you set where you are copying things to.


No I'm going to specify the Finder items. It's where I'm copying them to that is variable. It's the variable feature of Automator I haven't quite worked out yet.

Sep 2, 2008 2:08 AM in response to red_menace

red_menace wrote:
The following action returns the location of your Automator application - you can then put it into a variable, or whatever:


Thanks red, how do you then 'put it into a variable'? When I click on New Variable (in the New Folder action) all I can do is create a name and then choose a path. I can't figure how to tell it to use the path from the AppleScript.

Sep 2, 2008 2:35 PM in response to Christiaan

When you make a new variable, normally there is a display at the bottom of the workflow window that shows the variables and their values. As V.K. already said, you can just drag the button-looking thing with the variable name into whatever fields in an action that will take a value. I'm not sure what you are doing with the New Folder action, but for an example of using variables, the following workflow finds out what folder it is located in, creates a new folder, and then copies Finder Items to the newly created folder:

1) Run Applescript (with the Applescript posted earlier)
this gets the location of the folder of the workflow application
2) Set Value of Variable
give it whatever name you want, for example My Path
3) New Folder
give it whatever name you want, for example My Folder
drag the variable button named My Path into the Where: field
right-click in the action's header and select Ignore Input to clear results from previous actions
4) Set Value of Variable
give it whatever name you want, for example My New Folder
5) Ask for Finder Items (Type: files, Allow Multiple Selection)
right-click in the action's header and select Ignore Input to clear results from previous actions
6) Copy Finder Items
drag the variable button named My New Folder into the To: field

Sep 3, 2008 5:22 PM in response to Christiaan

OK, I am now going to try to teach you to fish 🙂

It might be a little bit easier to visualize if you think of the values passed along in your workflow as a stack of playing cards. Some actions do something with the cards and then just pass them on, some take all of the cards, and others add cards to the stack. The Set Value of Variable action takes the current stack of cards (the results of any previous action(s)), assigns it to a variable that is named whatever you want to name it, and passes the stack on to the next action. The Get Value of Variable gets the value of one of your previously named variables and adds it to the stack. You can also use a previously named variable in input fields of various actions, such as locations to copy to. I'm not sure why you are getting the path to the desktop (unless that is where your workflow application is located), but here are some additional comments for my previously posted workflow:

1) Run Applescript (with the Applescript posted earlier)
- if your workflow has been saved as an application, the results of this action will be a path to the folder that it is in (if not, the path will be to where the Automator application is, which isn't what you want)

2) Set Value of Variable
- this action will take that path, assign it to a variable with your specified name, and pass it on

3) New Folder
- this action makes a folder with the specified name in the specified location - you can drag variables into these fields, in which case their current values are what will be used
- the result of this action is a new folder, and the path to the folder is added to the current stack of cards (if any) and passed on to the next action
- since we just want the path to the new folder (and none of the previous cards), first we throw away any cards we may have (with the "ignore input" option) so that our results don't get mixed up.

4) Set Value of Variable
- same as (2) above, except that the value is now the path to the folder that got made in the previous action (3)

5) Ask for Finder Items (Type: files, Allow Multiple Selection)
- the results of this action will be whatever items you selected, and of course, they will be added to our current stack of cards unless we throw them away first with the "ignore input" option

6) Copy Finder Items
- this will copy Finder items (the ones we selected in the previous action) to the location that is specified - you can drag a variable into the To: field, in which case it's current value is what will be used.
- the result of this action will be the paths to the items that were just copied, but since this is the end of the workflow it doesn't matter

You can use the View Results action to see what the current stack of cards is, so you can see if what is going in and coming out of your actions is what you expect, and tweak accordingly.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Copying Finder items into same folder as Action

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