BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
djhanson
Community Trekker

Copy File() Doesn't Overwrite

Just fyi, Copy File() does not appear to overwrite.  If the destination file already exists the log will show a zero instead.  There also does not appear to be any switch possible (e.g. 1 = overwrite, 0 = no overwrite).

So I'm resorting to: Delete File() then Copy File() for cases where I want it to overwrite an existing destination file.

Just passing this along in case it help others.  I do appreciate these relatively new file utilities, they come in handy for sure. DJ

0 Kudos
4 REPLIES 4
msharp
Super User

Re: Copy File() Doesn't Overwrite

confirmed:

for(i=1,i<=2,i++,

  text = "test" || char(i);

  save text file("C:\TEMP\test.txt", text);

  copy = copy file("C:\TEMP\test.txt", "C:\TEMP\test2.txt");

  print(copy);

  text2 = load text file("C:\TEMP\test.txt");

  text3 = load text file("C:\TEMP\test2.txt");

  print(text2);

  print(text3);

)

//log

1

"test1"

"test1"

0

"test2"

"test1"

0 Kudos
djhanson
Community Trekker

Re: Copy File() Doesn't Overwrite

I'm just bumping this up in case there's a solution.  Problem is, having to Delete File () prior to Copy File () can take a long time...in my case 10 sec and that's for a very small file size.

 

If anyone knows any tricks to make Copy File () overwrite a file if it exists, let me know!  thanks, DJ

0 Kudos
txnelson
Super User

Re: Copy File() Doesn't Overwrite

I do not have a solution, but I do want to encourage you to report the issue to

     support@jmp.com

Jim
stephen_pearson
Community Trekker

Re: Copy File() Doesn't Overwrite

The save file functions do overwrite provided the target file is not being accessed by another program. Would a read file/write file JSL script allow your to overcome the current limitations of the copy file function?

0 Kudos