cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Copy File() Doesn't Overwrite

djhanson
Level V

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

4 REPLIES 4
msharp
Super User (Alumni)


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"

djhanson
Level V


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

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


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?