I’m sure this is something easily done, but i’m just a newby and not up to speed yet.
I’m after a script to duplicate a predetermined folders contents to another folder but not to copying the folder enclosed files, just the folder name, so they are essentially empty folders. It will also need to replace duplicates.
You seem to contridict yourself a little in your question!
So bare with me if i get this wrong.
I assume you have a folder with several other folders inside, and what you want to do is copy these internal folders into
another folder, but not whats inside them!!! so essentially your just copying the names of the folders:
try this:
tell application "Finder"
set p to folders of (choose folder) as alias list --pick a folder here
set t to (choose folder) --> choose where the folders will go here
repeat with n in p
set f to name of n
make new folder in t with properties {name:f}
end repeat
end tell
theres no overwriting in this script i can’t see the point if the folders you are creating are empty,
however i’m still a little bit unsure what you want. so see how you get on with the above script
Sorry, i wrote that kinda badly. But essentially you have it correct! All it needs is a replace if it finds a duplicate. You see, the first folders contents could change over time, and i want the second copyied folder to have every folder that was ever inside the first. So the script will add new folders, and just replace if it’s the same. Does this make sense?
Okay found this replacing statement but it won’t work. any ideas?
tell application “Finder”
set p to folders of (choose folder) as alias list --pick a folder here
set t to (choose folder) → choose where the folders will go here
repeat with n in p
set f to name of n
make new folder in t with properties {name:f} with replacing
end repeat
end tell
Your right the replacing bit doesn’t work.
i don’t think it works with folders just files.
what you need is a recursive script that goes into sub folders.
i think the tricky bit here is creating them at the other end if you like still in the same hierachy.
i’ll have a look but there’s guys on here that are better at this type of stuff than me.
so i’m sure someone else may throw there cap in on this one.
this terminal unixy command would maybe be another option for you.
rsync -r --include="*/" --exclude="*" folders to copy from here folder to go to here
just tested it and it copied folders and sub folders no files, it remembers whats been
synced as well so the second time you run it it will only update the new folders.
not sure how familiar you are with the terminal but this is pretty easy.
copy the rysnc----> “*” and paste into terminal then drag the folder you want copying onto the terminal then do the same with the destination folder then hit return.
Not sure if this is a solution but i think an applescript would be quite complicated.
Are you running an intel machine.
if so this might be the problem.
I’m not sure if it is exactly what you want anyhow.
i’ll try and have a look at the applescript route. in the meantime why don’t you “google” rsync
and see if the syntax has changed.
I must apologise up front regarding this script it is very crude.
But test it and see how it works for you and let me know if were going in the right direction.
tell application "Finder"
set e to every item of (choose folder)
set n to (choose folder)
duplicate e to n with replacing
set f to files of entire contents of n as alias list
repeat with i in f
delete i
end repeat
end tell
The last script may be crude, and that’s fine becuase it appears to work!
It does give an applescript error “Can’t make every file of <> of alias “HD:Users:thomas:Desktop:B:” into type <>”