Duplicate file to folder, but with a different name

In my script, I have a file in a folder that I want to duplicate to another folder. However, I want the duplicated file to be a different name. Is it possible to do this? The original file is on a network which doesn’t allow me to change the name before it’s duplicated.

I know the following is not right, but it’s an example of what I want:

duplicate file (CopyFile) to folder (TestFolder) renaming as file (NewCopyFile) replacing yes

Thanks for looking,


The simplest method is to use the shell script [cp]. It copies and renames a file all in one action. Here is the syntax:

set a to choose file --This is the file to be moved/renamed.
set b to quoted form of (POSIX path of a) --The [quoted form of POSIX path is a good idea when you are unsure of the naming style of the source file.
set c to path to desktop as Unicode text --This is an example for the destination of the renamed file.  The Unicode text parameter makes the folder 'readable' to the shell
set d to quoted form of (POSIX path of (c & "New File")) --Again, the quoted form of the POSIX path is always a good idea; keeps errors to a minimum.
do shell script "cp " & b & " " & d --Be sure to leave a space after the [mv] and in between the two file references.

Using this, you now have a file on your desktop that is exactly like the old one; just with a new name. You do need to be careful, though, because in this simple form, it will over-write any file already named [New File] and the old one will be lost forever. You can set the [cp] command to be more careful if you wish.

Good luck


thanks for your help Craig.
I tried out what you suggested without any success. I kept getting wierd errors and I had no clue what they meant. I’m just now learning AS; shell scripts will be phase 2.
I decided to go another route but I do appreciate your advice.
Thanks again - slimjim


No problem. If you still have your code that was throwing errors, why not post it here? I, or someone else, could take a look at it and see where the flaw is.

I could try to replicate the error tomorrow and post it but I think the problem might be due to the original file being on a network. I remember seeing “Permission Denied”. I’ll give it a whirl tomorrow.
Thanks - slimjim