backup

mdtools.file_handler.backup(fname)[source]

Backup a file by renaming it.

Check if a file with name fname already exists. If so, rename it to 'fname.bak_timestamp', where 'timestamp' is the time when the renaming was done in YYYY-MM-DD_HH-MM-SS format.

Parameters:

fname (str or bytes or os.PathLike) – The name of the file to backup.

Returns:

renamed (bool) – Returns True if a file called fname already existed and was renamed. False if no file called fname exists and no backup was done.