Automate file folder creation

scoy

Member
Does anyone know how to make a simple app or workflow with the Apple Automator? Here is what I need to do: Drag a file on a workflow that will create a folder by the same name as the file and then place that file in that folder, inside another folder named “mr”. As well as creating some other folders named ff/Hires and “NX” in the same folder. Example attached.
 

Attachments

  • photo5875.png
    photo5875.png
    35.1 KB · Views: 298
I am not the one to provide a workable answer, however I am sure that others can! I am probably going wrong somewhere with the following, either in the AppleScript or in the automator components. Anyway I fell over at the first step…

Good luck!


Stephen Marsh
 

Attachments

  • fubar.jpg
    fubar.jpg
    160.1 KB · Views: 297
Last edited:
Hello,

I've managed to sort this using Applescript.

In Automator create a new Application (where Application receives files and folders as input).

Then add an AppleScript Action.

Then copy and paste this script....


------------------------------------------------------------------------------------

on run {input, parameters}



tell application "System Events"



--- get the details of the first item



set myPOSIXitem to the POSIX path of (first item of input)

set myItemAlias to the first item of input as alias



-- build the name for the new folder



set myItemNameExtension to the name extension of myItemAlias

set myItemNameExtensionLength to the length of myItemNameExtension

set myPOSIXitemLength to (length of myPOSIXitem) - (myItemNameExtensionLength + 1)

set myNewFolderRoot to (characters 1 thru myPOSIXitemLength of myPOSIXitem) as string





-- make the folders



do shell script "mkdir -p " & the quoted form of (myNewFolderRoot)

do shell script "mkdir -p " & the quoted form of (myNewFolderRoot & "/ff")

do shell script "mkdir -p " & the quoted form of (myNewFolderRoot & "/ff/Hires")

do shell script "mkdir -p " & the quoted form of (myNewFolderRoot & "/mr")

do shell script "mkdir -p " & the quoted form of (myNewFolderRoot & "/NX")



-- copy the first item to the mr folder



set myPOSIXitem to the quoted form of myPOSIXitem



do shell script "mv " & myPOSIXitem & " " & quoted form of (myNewFolderRoot & "/mr")



end tell



return input

end run


------------------------------------------------------------------------------------

It will only work on one file dropped at a time (the others are ignored)

It won't work correctly if Folders are dropped on it.


Good Luck
 

Attachments

  • Screen Shot 2016-09-10 at 11.20.50.png.jpg
    Screen Shot 2016-09-10 at 11.20.50.png.jpg
    16.2 KB · Views: 289
Hello,

Here is the other variation. This is for anyone who just wants to move a file into a new folder with the same name as the original file.



------------------------------------------------------------------------------------

on run {input, parameters}



tell application "System Events"



--- get the details of the first item



set myPOSIXitem to the POSIX path of (first item of input)

set myItemAlias to the first item of input as alias



-- build the name for the new folder



set myItemNameExtension to the name extension of myItemAlias

set myItemNameExtensionLength to the length of myItemNameExtension

set myPOSIXitemLength to (length of myPOSIXitem) - (myItemNameExtensionLength + 1)

set myNewFolderName to the quoted form of ((characters 1 thru myPOSIXitemLength of myPOSIXitem) as string)



-- make the folder



do shell script "mkdir -p " & myNewFolderName



-- copy the first item to the new folder



set myPOSIXitem to the quoted form of myPOSIXitem



do shell script "mv " & myPOSIXitem & " " & myNewFolderName



end tell



return input

end run




------------------------------------------------------------------------------------

It will only work on one file dropped at a time (the others are ignored)

It won't work correctly if Folders are dropped on it.



If you want to do the same thing but ZIP up the folder then check out KeKa with its "Archive as single files" feature.

http://www.kekaosx.com/en/
 
Thank you Tim!

scoy, although you could make an automator app, I would recommend making a service, that way you can just right click on the input file - anywhere on the system, without having to have the application handy to drop the file onto, while a folder action could be used for a hotfolder based method.

This is the sort of stuff that this post was all about:

http://printplanet.com/forum/informa...pen-automation


Stephen Marsh
 
Last edited:
Great discussion here. I figured I would chime in from another perspective because we also automate our folder creation but do so a different way which doesn't rely on any operators.

We utilize Enfocus Switch for much of our automation and we use a common live jobs folder as the common repository for jobs files. The folder structure is the following: 'Live Jobs/{job_number}_{customer_name}' (Live Jobs/123456_My Customer/). As jobs move throughout Switch, we use the job number (often taken from the file name) to query our MIS for job information (in this case, the customer name). We then use those two variables to build the live jobs location path to reference that directory. The first time this path is used is in the creation of the job folder (similar to your case here). In Switch terms, this is called archive hierarchy.

In our MIS, we have a way to create a file whenever we convert a quote to a job, or create a new job. Switch watches for that file, and when found, kicks off the initial folder creation and setup, adding a few empty subfolders to the directory for prepress operators. When files are uploaded by the client, and assigned to job numbers, the originals are then saved to the same directory, in an 'originals' subfolder. Moments later, our preflight system finished preflighting the originals, and then the preflights are delivered to the location as well. Finally, the originals themselves are unpacked and placed into a folder which contains the authoring application (~Source InDesign 2015, for example). Later in the jobs lifecycle, the prepress operator creates and sends proofs via Switch, which also saves proofs to this directory in a 'PDF Proofs' subfolder. If the job is destined for an online storefront, thumbnails and storefront placement documents are generated and make their way to this directory. This is only possible because we can resolve the path to the live jobs files whenever we know the job number.

Later on, these files are automatically archived and can be retrieved via an automated system via Switch as well, also using this archive location path which stems from knowing the job number.
 
I have an AppleScript application that creates my folder structure. The only user input is job number and customer name, whether a PDF proof is needed, and which network share to copy the job folder to.

Cheers,
pd
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top