Directory backup

Easy function for creating a backup of a folder

Vous suivez désormais cette soumission

Creates a backup of folder 'a' in folder 'b' or updates the current backup in folder 'b'. The function deletes files and folders from directory 'b' if they are not present in directory 'a'. It also compares each file with the same name by date and if a difference is found, the files in folder 'b' are updated, provided the file in folder 'a' is found to be newer. However, if the file in folder 'b' is found to be newer than the file in folder 'a', the user is asked for confirmation of update. Currently, the code assumes a Windows (DOS) environment.

Matlab calls to delete files and directories are significantly slower than DOS calls.

A 'mode' argument can be used to determine the following:
-1: No backup performed. Trial run only with command line information (for checking before committing!).
0: Minimal user input mode. Only questions when the backup would involve updating a file that is newer in the backup directory. This is the default option.
1: Safe mode. Questions most actions (significant user input required to do a backup), except for copying (without overwriting) files/directories to the backup directory.

Being a free tool, this code comes with no warranty, but try it out on some test directories - it has saved me hours of backup-stresses and attempts to version-control.

Citation pour cette source

Philip Jonkergouw (2026). Directory backup (https://fr.mathworks.com/matlabcentral/fileexchange/19911-directory-backup), MATLAB Central File Exchange. Extrait(e) le .

Informations générales

Compatibilité avec les versions de MATLAB

  • Compatible avec toutes les versions

Plateformes compatibles

  • Windows
  • macOS
  • Linux
Version Publié le Notes de version Action
1.0.0.0

Removed bug in local function for deleting files using system (DOS) command. Hidden files were not deleted due to missing /AH switch.