I been a lurker for approx a month now and I have learned a lot from other people’s script. It’s time for me to take on a bigger script and I am having difficulty continuing.
I need help with my current script. Basically, this is what I want to accomplish.
Find the “high res” mount volume
Find the “low res” mount volume
Search high res mount volume for the folder names “Images” or “Hi_Res”
Once the folder names are located create similar path in the “low res” mount volume
Create folder paths for every folder inside “Images” or “H_Res”
I have got this far with my search on this site and a couple of references books. If you can point me to that direction, that would be fantastic.
set the_container to (choose folder with prompt "Select High Res:")
set des_container to (choose folder with prompt "Select Low Res")
set folder_type to {"IMAGES", "HI-RES"}
on search_and_create(the_container)
tell application "Finder"
set new_container to make new folder at des_container with properties {name:the_container}
set hi_res_folder_list to every folder of folder the_container whose name contains folder_type
repeat with the_folders in hi_res_folder_list
-- create new path in low res server
end repeat
set container_list to (folders of container the_container)
repeat with the_sub_container in container_list
set the_sub_container to (the_subcontainer as string) as alias
my search_and_create(the_sub_container)
end repeat
end tell
end search_and_create
set new_container to make new folder at des_container with properties {name:the_container}
“name:the_container” is actually an alias pointing to the folder that has been chosen. To get the name of that particular folder place this line inside the “tell application “Finder””:
set foldName to name of the_container
and replace “name:the_container” with “name:foldName”.
or use this:
tell application "Finder"
set new_container to make new folder at des_container with properties {name:(name of the_container)}
end tell
For a path to your “des_container” use
set destinationPath to des_container as string
then with your repeat statement you can do this:
repeat with the_folders in hi_res_folder_list
duplicate the_folders to destinationPath -- add "with replacing" here to replace a file if it already exists or else use if statements to check for existing files/folders.
end repea
Also it looks as though you’re trying to do a recursion of this in order to create all folders and subfolders of the folder originally chosen. You need a “call” to this subroutine/handler. After the last “set” statement you need to add
search_and_create(the_container)
If this line were inside a “tell” block you would add “my” in front (my search_and_create(the_container)
You could also use this line for volumes:
tell application "Finder"
if not exists disk "yourDiskName" then
mount volume "afp://userName:password@155.155.155.155/hardDriveName"
end if
end tell
I haven’t looked long enough or tested this yet to see if it works, but this should get you a start.