Force rename and replace old file

Find quick help here to get you started with Hollywood
Post Reply
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Force rename and replace old file

Post 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
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: Force rename and replace old file

Post 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$)
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Force rename and replace old file

Post by papiosaur »

Thanks Bugala!

It's a good idea :-)

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