On Jan 12, 2010, at 2:19 PM, Oakley Masten wrote:
Hi All
Got a question that I just can't find a simple answer to.
I want to duplicate files from a local folder to another folder on a server
I will then move the file into a subfolder called "Processed" on the local machine.
Doing this is easy - so here is the question.
How do I change the name of the duplicated file on the server at the time of duplication.
I would think that"
Tell application "finder"
set theFile to choose file
duplicate theFile to Destination folder path on server with properties {name:"NewNameForFile.txt"}
end tell
But it doesn't.
You're right, it doesn't. (It ought to.) Ran into the same problem some time ago.
on copyFile(fileAlias, targetAlias, newFileName)
-- fileAlias is an alias to the source file, targetAlias is an alias to the destination folder and newFileName is a string
set sourcePath to (quoted form of POSIX path of fileAlias)
set targetPath to (quoted form of (POSIX path of ((targetAlias as text) & newFileName)))
try
do shell script "cp -np " & sourcePath & space & targetPath
return ((targetAlias as text) & newFileName) as alias
end try
return {}
end copyFile --------------------------------------------------------------------
It preserves all the source file's properties except 'comment'.
I've been using this for some months and it just works.