Page 1 of 1

Force rename and replace old file

Posted: Sat Aug 12, 2023 8:03 am
by papiosaur
Hello,

it will be possible to add a"force" option to Rename() ?

Example, i have this two file

file1.txt
file2.txt

I would like to rename file1.txt to file2.txt and overwrite file2.txt.

Thanks

Re: Force rename and replace old file

Posted: Sat Aug 12, 2023 9:09 am
by Bugala
I guess you just need to use Exists() to check if file2 exists, if it does, delete it, then rename the file1 to file2.

Code: Select all

Function My_Rename(OldFileName$, NewFileName$)

if Exists(NewFileName$) then DeleteFile(NewFileName$)
Rename(OldFileName$, NewFileName$)

endfunction
usage same as default Rename Command:

Code: Select all

My_Rename(File1$, File2$)

Re: Force rename and replace old file

Posted: Sat Aug 12, 2023 9:42 am
by papiosaur
Thanks Bugala!

It's a good idea :-)

I don't think to create a function and use it...