PDA

View Full Version : create folders applescript




joennie
Jul 29, 2013, 06:07 AM
I have a folder with x ammount of subfolders which all contain images.

I need to create the same folder structure but within each folder I need to create a 2 folders, thumbnails and fullsize images and then process each original folder and insert the images into the correct folders

Current format

main folder > imagefolderone > img1
img2
img3

imagefolderone > img1
img2
img3

Required format

main folder > imagefolderone > thumbnail_folder >
thumbnail image1
thumbnail image2
thumbnail image3
main_folder >
main image1
main image2
main image3

> imagefoldertwo > thumbnail_folder >
thumbnail image1
thumbnail image2
thumbnail image3
main_folder >
main image1
main image2
main image3



Red Menace
Jul 29, 2013, 07:43 PM
There are several different ways to create folder structures, but sometimes it is easier to create the desired structure using the normal Finder commands, and then copy the template as needed.

on run -- example
copyFolderStructure from (choose folder with prompt "choose source folder") to (choose folder with prompt "choose destination folder")
end run

to copyFolderStructure from sourceFolder to destinationFolder
tell application "Finder"
repeat with someFolder in (get folders of sourceFolder)
get name of someFolder
try
make new folder at destinationFolder with properties {name:result}
on error number -48 -- ignore duplicate file name, but continue traversing the structure
get ((destinationFolder as text) & result) as alias
end try
my (copyFolderStructure from someFolder to result)
end repeat
end tell
return
end copyFolderStructure

joennie
Jul 30, 2013, 12:02 AM
Thanks so much...if I want to add a generic thumbnail folder, would that be done in the same code, or would I run a separate applescript

Red Menace
Jul 30, 2013, 06:43 PM
You can add folders to the template and use the same script to update an existing structure.