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

rename files dynamically with automator

hi community,


i've read about the possibility to rename files with otto the automator. the usually described ways work fine.


Open automator -> choose rename files -> choose from the adjustment possibilities available -> state the files -> press play.


in my case i want a bunch of files (pictures) to start with a particular word, e.g. a sight we have visited (e.g. mountains). another bunch of files are supposed by a differened sight, e.g. lakes.


with the above mentioned process, each time i hace to select the files, drag & drop them into automator, change the wanted prefix and run the automation. because the prefix is changing for each bunch of files, to build a service doesn't really make sense, in my opinion.


now, what i would like to have automated and made a service of is that the above mentioned process is interrupted by a pop up that asks me for the text i want to put in front of the filename and the goes on. i tried to play around with the "Ask for text" element and succeed with the "Rename Finder Items" element. unfortunately, the answer i give in "Ask for text" will not be used as the text attribute in the following step "Rename Folder Items". i miss something that conects the two elements and tells automator what to do with the text i've given as an answer.


of cource any other convenient solution to dynamically rename file names is welcome as well. i just thought this would be a good task for automator to do for me 🙂


thanks for your help and ideas already in advance!


cheers

dave

Posted on May 21, 2014 11:02 AM

Reply
Question marked as Best reply

Posted on May 21, 2014 12:56 PM

Each action usually has an option to show it when the workflow is run, so if your workflow is fairly simple you can just use that and fill in the details at run time.


The usual way to use items in other actions is to use variables, for example:

  1. Service receives selected files or folders in the Finder
  2. Set Value of Variable { Variable: inputFiles } -- save the original input for later
  3. Ask for Text (Ignore Input) -- get the text to add to the file name ...
  4. Set Value of Variable { Variable: prefix } -- ... and save it in a variable so that it can be used later
  5. Get Value of Variable { Variable: inputFiles } (Ignore Input) -- get the original items back
  6. Rename Finder Items { Add text before name } (drag prefix variable to text field)


Each action also usually has an option to ignore the items input to it - in my example, steps 3 and 5 use it to keep the previous results from getting mixed in.

6 replies
Question marked as Best reply

May 21, 2014 12:56 PM in response to mac-a-rooney

Each action usually has an option to show it when the workflow is run, so if your workflow is fairly simple you can just use that and fill in the details at run time.


The usual way to use items in other actions is to use variables, for example:

  1. Service receives selected files or folders in the Finder
  2. Set Value of Variable { Variable: inputFiles } -- save the original input for later
  3. Ask for Text (Ignore Input) -- get the text to add to the file name ...
  4. Set Value of Variable { Variable: prefix } -- ... and save it in a variable so that it can be used later
  5. Get Value of Variable { Variable: inputFiles } (Ignore Input) -- get the original items back
  6. Rename Finder Items { Add text before name } (drag prefix variable to text field)


Each action also usually has an option to ignore the items input to it - in my example, steps 3 and 5 use it to keep the previous results from getting mixed in.

May 27, 2014 10:28 AM in response to red_menace

hi red_menace,


that sounds actually very much as I hoped it is going to work. What I couldn't figure out yet is HOW to set the option to show an action during runtime.


From your comment I understand however, it is possible, that instead of dragging and dropping the files from a finder window into automator and run the workflow there, it might also be possible to be asked for the files I want to rename during runtime, while the workflow has been startet as a service from anywhere in OS X without any need for the automator to be open at this time, right?

May 27, 2014 10:36 AM in response to red_menace

Hi red_menace,


stupid me! Like the one how's too stupid to google himself.... sorry.


I found the action "Ask for Finder Items" --> that's cool!


I found the option checkbox "Show this action when workflow is executed" --> that makes it dynamically enough for my purpose!


What I still don't get is what you do with the variables and how you define them?


cheers

david

May 27, 2014 11:55 AM in response to mac-a-rooney

Automator variables are just storage containers that can be used as a place to put objects in. There are a few pre-defined variables in the Automator library that you can use such as locations in the file system or date/time, and double-clicking on them will add it to your workflow variables. You can define your own variables in the workflow with the Set Value of Variable action, and insert a variable into the workflow with the Get Value of Variable action - note that this will add to the current set of items being processed by the workflow.


The variables in a workflow can also be added, removed, and edited in the variable list at the bottom of the workflow window, which can be viewed by using the toolbar buttons at the bottom of the window or the View menu. In addition to the Get/Set actions mentioned above, a variable can be used in an action (if appropriate and it is designed to use them) by dragging it into one of the action's text fields. Typical uses would be to create a name or date for use in an action (the prefix variable in my previous example), or saving/restoring the results from a previous action (the inputFiles variable in my previous example).

rename files dynamically with automator

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