Apple Event: May 7th at 7 am PT

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

Automator-Create new folder from file name and move file

Hi everyone. Looking for some light here. I don't know scripinting but need to create either an service, workflow or application from Automator to do this:


During a week I create several files to the printing house. I usually work from the editable (master) file. From there I create a high quality PDF. Afterwards I create a High res JPG (300 dpi - cmyk), and a low res JPG file (75 dpi - RGB). I add LOW to the file name to the low res JPG. As a result I have this example files:


1) newspaper ad 15x35.ai

2) newspaper ad 15x35.pdf

3) newspaper ad 15x35 LOW.jpg

4) newspaper ad 15x35.jpg


So for every master file I create 3 more files. During an average week I generate an average of 40 master files, resulting 160 files! All mixed in one single project folder. When I finish my work, I copy the file name from my AI document, and then manually I select this for files and move them into the file. Doing this for 5-8 master files is ok, but some weeks we have a huge amount of file and really need a way to automate this.


What I need is to create a new folder with the exact name of my AI document, and then move the rest of the files to that new folder, resulting this:


(folder) newspaper ad 15x35

inside) newspaper ad 15x35.ai

inside) newspaper ad 15x35.pdf

inside) newspaper ad 15x35 LOW.jpg

inside) newspaper ad 15x35.jpg


Note that there is one file which has the LOW word added. Anyone has a clue how to achieve this with automator?

Thanks in advance!

iMac, Mac OS X (10.6.7)

Posted on Feb 13, 2013 10:32 AM

Reply
Question marked as Best reply

Posted on Feb 13, 2013 2:31 PM

Automator can be a pain never use it for more then the most basic of things. What you want to do may be possible in it but it seems a straight Appelscript solution would be easier.


This is the beginnings of a script that does what you are looking to do (at lest as I understand it). There are most likely better ways to do this, I'm no Applescript expert and I'm sure others will jump i but this should give you an idea.


There is no error checking and the folder name for top level folder is Test in the Desktop. It also wasn't clear where you want the destination folder to be. This places it in the same folder with the files (Test in this case).


It also assumes the master files extension is always 'ai'.


set theFolder to (((path to desktop) as text) & "Test") as alias

tell application "Finder"
          set fileList to name of every file of theFolder whose name extension is "ai"
end tell

set text item delimiters to "."

repeat with theFile in fileList
          get every text item of theFile
          set masterFile to item 1 of result
          tell application "Finder"
  make new folder at theFolder with properties {name:masterFile}
                    move (every file of folder theFolder whose name contains masterFile) to result
          end tell
end repeat
8 replies
Question marked as Best reply

Feb 13, 2013 2:31 PM in response to alexgsrubio

Automator can be a pain never use it for more then the most basic of things. What you want to do may be possible in it but it seems a straight Appelscript solution would be easier.


This is the beginnings of a script that does what you are looking to do (at lest as I understand it). There are most likely better ways to do this, I'm no Applescript expert and I'm sure others will jump i but this should give you an idea.


There is no error checking and the folder name for top level folder is Test in the Desktop. It also wasn't clear where you want the destination folder to be. This places it in the same folder with the files (Test in this case).


It also assumes the master files extension is always 'ai'.


set theFolder to (((path to desktop) as text) & "Test") as alias

tell application "Finder"
          set fileList to name of every file of theFolder whose name extension is "ai"
end tell

set text item delimiters to "."

repeat with theFile in fileList
          get every text item of theFile
          set masterFile to item 1 of result
          tell application "Finder"
  make new folder at theFolder with properties {name:masterFile}
                    move (every file of folder theFolder whose name contains masterFile) to result
          end tell
end repeat

Mar 6, 2013 10:45 PM in response to alexgsrubio

Here is an automator action you can start with. I think I now what you are trying to do.


Let me know if this does not work for you.


Ask for text

  • Question: What basename of files do you want to find and move into a new folder?
  • Answer: newspaper ad 15x35 [default answer I put it, you can leave this blank and enter the basename]

Copy to Clipboard

Set Value of Variable

Variable Name: basename

Find Finder Items

  • Search Computer
  • All of the following are true:
  • Name Contains [you will be prompted to fill this out. Hit Control V and it will paste the basename]

Get Selected Finder Items

New Folder

  • Name: basename (variable name as above)
  • Where: Desktop (or as you wish)


Under FInd Finder Items, you need to select Options and then click on "Show this action when workflow runs"


Here it is for you to download:


http://cl.ly/3a201f1X0p1d/download/Untitled.workflow.zip


Message was edited by: pjdube

Jan 6, 2016 4:07 PM in response to Frank Caggiano

Sorry to revive an old thread, but this is the exact issue I am currently having. I run that script and I get


error "Finder got an error: The operation can’t be completed because there is already an item with that name." number -48

And this section is highlighted.

makenewfolderattheFolderwith properties {name:masterFile}

I set "Test" to the name of the folder I want to work in, which is "Badges copy" but that's the only edit I made.

If you are still out there and willing, I'd definitely appreciate the help.

Sam

Automator-Create new folder from file name and move file

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