Most efficient way to copy and then delete files from iDisk...

K, this is my first stab at this. On my iDisk I created 35 main folders each with 4 subfolders where documents are going to be placed. Basically, it’s a mirror of the folders on my HD. I want my assistant to be able to put the documents she creates in these subfolders. I then want to run this script which will file her documents (regardless of the name she gives them) in the appropriate place on my HD (I don’t want to give her SSH access to my computer). So, wrote this Script to copy her files from my iDisk, save them in their respective folders on my HD, and then delete the iDisk files from the iDisk. Turns out, it’s going take a lot of typing to accomplish this! Anwyay, here’s what I got so far. This represents only 2 of the 35 main folders that I have to make a script for. So, is the code ok? Is there a better way? Is there another way to do the other 33 besides manually making the changes??? Thank you…

tell application “Finder”

set fold_path to folder "II.  Bills" of folder "ALLEN" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path2 to folder "II.  Bills" of folder "Allen" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path to fold_path2

select every file of fold_path
delete selection

set fold_path3 to folder "III. Correspondence" of folder "ALLEN" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path4 to folder "III. Correspondence" of folder "Allen" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path3 to fold_path4

select every file of fold_path3
delete selection

set fold_path5 to folder "IV. Disc/Stips/Misc" of folder "ALLEN" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path6 to folder "IV. Disc/Stips/Misc" of folder "Allen" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path5 to fold_path6

select every file of fold_path5
delete selection

set fold_path9 to folder "VIII.Write-ups" of folder "ALLEN" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path10 to folder "VIII.Write-ups" of folder "Allen" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path9 to fold_path10

select every file of fold_path9
delete selection

set fold_path13 to folder "II.  Bills" of folder "ANDRADE" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path14 to folder "II.  Bills" of folder "ANDRADE" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path13 to fold_path14

select every file of fold_path13
delete selection

set fold_path15 to folder "III. Correspondence" of folder "ANDRADE" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path16 to folder "III. Correspondence" of folder "ANDRADE" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path15 to fold_path16

select every file of fold_path15
delete selection

set fold_path17 to folder "IV. Disc/Stips/Misc" of folder "ANDRADE" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path18 to folder "IV. Disc/Stips/Misc" of folder "ANDRADE" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path17 to fold_path18

select every file of fold_path17
delete selection

set fold_path19 to folder "VIII.Write-ups" of folder "ANDRADE" of folder "*** WWW ***" of folder "Public" of disk "iDisk"

set fold_path20 to folder "VIII.Write-ups" of folder "ANDRADE" of folder "  ** BOXES **" of folder " WWW" of folder "Documents" of folder "radio" of folder "Users" of startup disk

duplicate every file of fold_path19 to fold_path20

select every file of fold_path19
delete selection

end tell

whoops, that isn’t working right. It’s deleting my entire Public folder. :confused:

Any ideas?

(edit: sorry, just realized this is in the wrong forum)

Excellent! Got is working after several tries (problem was mine). Now I’m thinking that the auto delete scares me so I removed it. However, I keep getting an “error” message when I go and try to re-run the command if the a file has already been copied to my HD in the past. Is there a way to tell it that if the document already exists in the HD, to just ignore it and keep going? Thank you so much for this great lesson.

…and finally, can I have it just copy any subfolders and their contents that are added to one of my existing iDisk folders (like if she adds a “Phone” sub-folder to the “II. Bills” folder)? :slight_smile:

You are the greatest, thank you. I really phrased my question poorly that you tried to address in the very last part. I should have said that I want to copy any new"SUB-subfolder" (and their contents) that my assitant might create in any of the 10 subfolders on the iDisk.

With that in mind, would the following code be correct (I now have a total of 10 subfolders)?

set my_subfolders to {“** Research ", " Records **”, “I. Complaints”, “II. Bills”, “III. Correspondence”, “IV. Disc/Stips/Misc”, “V. EBTs”, “VI. Experts & Exchanges”, “VII. Motion”, “VIII.Write-ups”}

set ThisFolder_iDisk to alias “iDisk:Public:*** WWW ***:”
set ThisFolder_home to alias ((path to startup disk) & “:Users:radio:Documents: WWW: ** BOXES **:” as string)

tell application “Finder”
set theseFolders to folders of ThisFolder_iDisk --35 folders
repeat with i in theseFolders --ALLEN, ANDRADE,etc…
set this_name to name of i
repeat with k in my_subfolders
set fold_path to folder k of i
repeat with thisFile in (get files of fold_path)
try
duplicate thisFile to folder k of folder this_name of ThisFolder_home
end try
end repeat
end repeat
end repeat
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end repeat – I ADDED THESE 6 BECAUSE I ADDED 6 NEW SUBFOLDERS
end tell

If so, I am confused about where to add the part about copying any new [b]SUB-{/b]subfolders…
In otherwords, I want to restrict my assistant to filing things in the 1 to 10 subfolders that I set up, and I then want to be able to run this script to copy her stuff to my HD.

However, I ALSO want to allow her to create SUB-subfolders to any of the 10 subfolders. For example… She might save a couple individual files in the subfolder “Research” but then she might create a couple SUB-subfolder in “Complaints” called “English Complaints” and “Spanish Complaints” and of course she might save several individual documents in these SUB-subfolders. So, how and where do I add the code to do that? Am I even coming close to making sense? :frowning:

You might want to take a look at the command line utility rsync (type “man rsync” in the Terminal).

Unfortunately, I’m GUI only. However, you really lead me to a great product. Thank you.

This is amazing! It’s exactly what I need, it’s amazingly fast, and it’s free. Thank you both.