Peter Reid wrote/ schreef:
> I'm using the following script to copy a file from one folder to
> another where it may or may not already exist (Mac MC 2.3.2,
> buildnumber 6):
>
> put URL ("binfile:" & origFilePath) into URL ("binfile:" & newFilePath)
>
> The problem was the origFilePath which was of the form "/Mac
> HD/sourcefile1.txt", i.e. I'd forgotten to insert a "/" between the
> path and the file name.
>
> What's interesting is that I got no error messages and it appeared to
> work, but produced empty destination copies. Once I'd spotted the
> error and corrected the source file path, it worked fine!
You could use
if there is a file <path> to test for this. Here's the code from a
project I happened to write just two days ago :-) It adds the
complexity that it's copying files from subfolders. The files are
organized into folders a through z based on the first letter of the
filename. I've added a few comments relevant to you.
on mouseup
set the filetype to "NqstAIFF"
put fld "source folder" & "/" into sourceFolder
put "binfile:" & fld "target folder" & "/" into targetFolder
put empty into fld "errors"
repeat for each line L in fld "word list"
put L into fld "current file"
put sourceFolder & (char 1 of L) & "/" & L into sourceFile
if there is a file sourceFile then --this is the bit you're looking for
put "binfile:" & sourceFile into sourceFile --there's a file, so copy
put targetFolder & (char 1 of L) & "/" & L into targetFile
put url sourceFile into url targetFile
else
put L & cr after fld "errors" --there wasn't a file, so log the problem
end if
end repeat
end mouseup
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.