Hi Phil,On May 28, 2011, at 2:21 PM, Philip Giles wrote: I'm new to this list and automator, so hello to all.
I was wondering if anyone could help me with making an 'action'. I'm looking to get an Automator application created that I could place on my desktop to do the following when I drop a folder of image files on it.
As part of my work flow as a photographer, I create folders that contain either 36 or 60 images. What I want the automator application to do, when I drop a folder on it is:
1) Create 6 new folders within the main folder, with the new folders named 1 though to 6 2) Move the image files in the main folder to each of the new folders, with every 6th images being moved to folder 1, then the next set to folder 2 and so on.
If there were 36 images in the main folder they would end up in the 6 folders as follows:
folder 1: images 1, 7, 13, 19, 25, 31 folder 2: images 2, 8, 14, 20, 26, 32 folder 3: images 3, 9, 15, 21, 27, 33 folder 4: images 4, 10, 16, 22, 28, 34 folder 5: images 5, 11, 17, 23, 29, 35 folder 6: images 6, 12, 18, 24, 30, 36
If there were 60 images in the folder, they would be sorted as follows:
folder 1: images 1, 7, 13, 19, 25, 31, 37, 43, 49, 55 folder 2: images 2, 8, 14, 20, 26, 32, 38, 44, 50, 56 folder 3: images 3, 9, 15, 21, 27, 33, 39, 45, 51, 57 folder 4: images 4, 10, 16, 22, 28, 34, 40, 46, 52, 58 folder 5: images 5, 11, 17, 23, 29, 35, 41, 47, 53, 59 folder 6: images 6, 12, 18, 24, 30, 36, 42, 48, 54, 60
3) Rename each set of sorted images, now in the individual folders, to image001, image002, image003, image004, image005 etc etc
So the end result would be 6 new folders, each with 6 or 10 images in them, and each set of images renamed as above.
Is it possible to do something like this in Automator? Any help would be much appreciated.
One problem you will run into with Automator is it's lack of branching logic. It doesn't have the ability to analyze situations and take different courses of action based on the result. You may be able to create a workflow that will do this, but it will likely be somewhat long and complicated, using variables, filter actions, and more. Your best bet would be to use AppleScript.
1. Create an Application workflow in Automator
2. Insert a "Filter Finder Items" action and configure it to filter for items whose kind is folder
3. Insert a "Run AppleScript" action and enter the following…
on run {theFolders, parameters} -- Loop through the input folders repeat with a from 1 to (count theFolders)
-- Get the current folder set theCurrentFolder to item a of theFolders
-- Get all files in the current folder, sorted by name tell application "Finder" set theFiles to sort every file of theCurrentFolder by name
-- Loop through the files repeat with b from 1 to length of theFiles set theCurrentFile to item b of theFiles
-- Determine the current output subfolder name set theCurrentSubfolderNum to (b mod 6) as string if theCurrentSubfolderNum = "0" then set theCurrentSubfolderNum to "6" repeat until length of theCurrentSubfolderNum is greater than or equal to 3 set theCurrentSubfolderNum to "0" & theCurrentSubfolderNum end repeat set theCurrentSubfolderName to "pano" & theCurrentSubfolderNum
-- Create the subfolder if it doesn't exist if (folder theCurrentSubfolderName of theCurrentFolder exists) = false then make new folder at theCurrentFolder with properties {name:theCurrentSubfolderName}
-- Move the current file to the current subfolder move theCurrentFile to folder theCurrentSubfolderName of theCurrentFolder end repeat end tell end repeat return {} end run
4. Save your workflow and drop a folder onto it to process it.
Hope this helps.
-Ben
Ben Waldie President Automated Workflows, LLC 484.744.1831 ============================================= AppleScript * Automator * Workflow Automation Products, Training, Custom Development Services =============================================
|