NOOB: what's wrong with my path?

Greetings. Just picked up a basic book and started scripting yesterday. I am having difficulty with file paths. For some reason the following code doesn’t work:

tell application "Finder"
	duplicate every file of "G5_HD:Users:me:test1" to folder "G5_HD:Users:me:test2" with replacing
end tell

It returns the following error: Can’t get every file of “G5_HD:Users:me:test1”

The problem I have with this is that if I replace the frist path with the ability to simply choose the file then it transfers the files with no problems to the test2 folder. How is it possible that two folders that are at the same level and with the exact same parent path work differently?

Also, are there any suggestions for good path standards? I would really prefer not to hardcode the name of the hardrive and instead right something like → of startup disk, but I can’t get that type of notation to work with the above “:” path format. I would prefer these scripts to be as portable as possible.

Please again excuse my ignorance with AppleScript. I do do some OOP, but find this applescript a bit bizarre.

-i

Hi iPhotoStuff,

This section:

every file of “G5_HD:Users:me:test1” to folder “G5_HD:Users:me:test2”

You used a string “G5_HD:Users:me:test1” in the original location and a proper reference folder “G5_HD:Users:me:test2” as the destination. Also, folder paths should end with “:”. An easy way to not make mistakes is to always use alias references.

every file of alias “G5_HD:Users:me:test1:” to alias “G5_HD:Users:me:test2:”

Note that folders end with colon. If you want a reference to current user use ‘patth to’. Example:

set user_path to (path to “cusr” as string)
set folder1_reference to (user_path & “test1”) as alias

This returns the an alias reference to a folder named “test1” in the current user’s folder. Similarly, you could get the reference to the other folder and use these in your duplication.

Note that Finder can use all types of references, but when getting references with the Finder, you get a Finder reference. Ex:

folder “test1” of folder “me” of folder “Users” of startup disk

Just so you don’t get mixed up in the future.

gl,

You want every file in a folder named test1, but don’t say so:

duplicate every file of folder "G5_HD:Users:me:test1" to folder "G5_HD:Users:me:test2" with replacing

AppleScript understands the “path to” quite a number of places that are machine independent:

so in your case, path to home folder reaches the top level where you have test1, so you want as a path:

set pathToT1 to (path to home folder as text) & "test1"
set pathToT2 to (path to home folder as text) & "test2"
tell application "Finder" to duplicate every file of folder pathToTest1 to folder pathToTest2 with replacing

Adam, Kel,

Thanks for the help. The path works properly now. Adam, I like your string method. Who knew there was an entire forum full of people that use appleScript?!!

-i