Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using shell to delete a file
#6
(04-24-2024, 10:05 AM)a740g Wrote:
(04-24-2024, 08:26 AM)PhilOfPerth Wrote: It works! Thank you.
Now, onward and upward!  Big Grin
Is there a  function to create a "backup" of a file, (say myfilebak, from myfile)?

There are no commands to directly make copies or backup of files. But you could write one with a few lines of code like:

Code: (Select All)
' Copies src to dst
' Set overwite to true if dst should be overwritten if present
SUB CopyFile (src AS STRING, dst AS STRING, overwrite AS _BYTE)
    IF _FILEEXISTS(src) THEN
        IF NOT _FILEEXISTS(dst) OR (_FILEEXISTS(dst) AND overwrite) THEN
            _WRITEFILE dst, _READFILE$(src)
        END IF
    END IF
END SUB

Thanks again.
That code stretched my primitive mind to its fullest extent, but I eventually interpreted it to Phil-ese, to read:

If the original (src) exists, then
 if there’s no backup (dst), or there is a backup but overwrite is set, then copy the src to dst
write the original to backup

Now, to try it!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Messages In This Thread
Using shell to delete a file - by PhilOfPerth - 04-24-2024, 06:43 AM
RE: Using shell to delete a file - by a740g - 04-24-2024, 06:48 AM
RE: Using shell to delete a file - by PhilOfPerth - 04-24-2024, 08:14 AM
RE: Using shell to delete a file - by PhilOfPerth - 04-24-2024, 08:26 AM
RE: Using shell to delete a file - by a740g - 04-24-2024, 10:05 AM
RE: Using shell to delete a file - by PhilOfPerth - 04-24-2024, 11:13 AM
RE: Using shell to delete a file - by Pete - 04-25-2024, 01:34 AM
RE: Using shell to delete a file - by PhilOfPerth - 04-25-2024, 05:04 AM



Users browsing this thread: 1 Guest(s)