Directory Clean-up

Automatically clean up a directory by moving files to a sub-directory.
1.2K Downloads
Updated 24 Nov 2004

View License

Clean up a directory by moving or copying files into a subdirectory based on the files creation date. Can be used to move results from script that generates output files.

[] = DirCleanUp(in,flag_copy,newdir,dirname,readmefile);

in = [30;10] -> move/copy all the files from -30 days to -10 days form now into a new directory
in = 30; -> move/copy all the files from -30 days to now into a new directory
"in" can be in datevec format [2003 10 13 17 43 00] for [year month day hour min sec]
flag_copy -> if 1 copy, else move the files, default is move
newdir -> new directory name, default is "test_currentdate"
dirname -> the directory to be cleaned up, if not given ask for directory
readmefile -> file to be copied in the new directory as "readme.txt"

examples:
DirCleanUp(24,1,'Toto','C:\temp');
copy all the files of the last 24 hours from c:\temp into C:\temp\Toto

DirCleanUp([2000 01 01 00 00 00;2000 12 31 23 59 59],[],[],[],'toto.txt');
move all the files from january 1st 2000 to december 31st 2000 into the subdirectory test_23-Nov-2004_11-29-45 of the directory selected by the user (using uigetdir), and copy the file toto.txt in the new directory to readme.txt

Cite As

Olivier Salvado (2024). Directory Clean-up (https://www.mathworks.com/matlabcentral/fileexchange/6372-directory-clean-up), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on File Operations in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0