Automator: Create new folders from .csv file and put images inside.
I have a challenging Automator task to achieve. I need to
1) create a set of folders labeled with the contents in column A of a csv file. (example: column A1 JoeBrown A2 SuzyBrown A3 JimBrown etc..) resulting in
3 folders titled JoeBrown, SuzyBrown, and JimBrown
2) take the image represented by an image number in column B of the same csv file and move that file into the folder that was created (example: A1 JoeBrown gets a folder created by the name JoBrown and column B IMG_1234.jpg is physically moved from within the same folder as the .csv file into the folder created by column A.
Both the csv and img files would be in the same folder. I have the script to create a set of folders from a csv list just can't complete the moving of files based on the contents of column B.
SUMMARY: I have a folder containing several images img_0001, img_0002, img_0003 etc. and a csv file that contains columnA a series of names and column B a series of jpg image numbers. I need to have a script that will create folders labeled whatever name is in column A (see the script below. it works great!) then move the images from column B to the folders generated from column A.
The csv script is:
tell application "Finder"
set mgFolder to container of mgCSVfile as string
repeat with x from 1 to count paragraphs of mgList
set text item delimiters of AppleScript to ","
set mgThisList to text items of paragraph x of mgList as list
set text item delimiters of AppleScript to ""
set mgTopFolder to item 1 of mgThisList
if (exists folder mgTopFolder of folder mgFolder) is false then
make new folder at mgFolder with properties {name:mgTopFolder}
end if
set mgNewFolder to (folder mgTopFolder of folder mgFolder) as alias
repeat with i from 2 to count mgThisList
if item i of mgThisList is not "" then
set mgSubFolder to item i of mgThisList
if (exists folder mgSubFolder of folder mgNewFolder) is false then
make new folder at mgNewFolder with properties {name:mgSubFolder}
end if
end if
end repeat
end repeat
end tell
Thanks for any help that may come my way.
OS X Mavericks (10.9.2), Applescript