getfiles.m
GETFILES Creates a list of files from optional file extensions and/or keywords in all folders and subfolders in current or supplied directory. NOTE: This code has not been evaluated on MAC OS machines and most likely will not work on them due to the system notation.
___________________________________
SYNTAX :
FileList=GETFILES(Input1,...,Input3)
________________________________________
INPUTS :
NOTE: Input order does not matter,however there can only be a maximum of 3 inputs.
File Keyword/Extension :
-Any File Extension in '*.*' format. If no file extension input is provided, output will be all files within specified directory.
-Keywords can also be provided to narrow search where asterisk (*) is a wildcard(example:
'*sample*.csv' will output all files ending in sample___.csv such as fastsample1.csv or sample0132.csv).
-Multiple filenames can be provided, separated by spaces (in the form '*.ext1 *.ext2' where all of the files of all of the extensions listed will be output.
-Any of the above can be combined to create large keyword/extension combinations.
Directory : Location of folder to search within. If no directory is provided, the current working directory will be used. NOTE: Supplying a directory will add that directory to the current working directory. To return to old directory,use CD.
Specific Files: Matrix used to select specific files from output list. If no matrix is provided entire list will be output.
________________________________________
EXAMPLES :
FileList=GETFILES;
Outputs a list of all the files in the current working directory.
FileList=GETFILES('*.csv');
Outputs a list of all of the *.csv (comma separated value) files in the current working directory.
FileList=GETFILES('*sample.csv');
Outputs a list of all of the files ending in sample.csv in the current working directory.
FileList=GETFILES('C:\Program Files\MATLAB\R2013a\licenses')
Outputs a list of all of the files in the licenses folder (and any subfolders) of the licenses folder in the MATLAB program files.
FileList=GETFILES([1,3:5,18])
Outputs files 1, 3, 4, 5, and 18 from the sorted list of the files in the current working directory.
FileList=GETFILES('*.txt', 'C:\Program Files\MATLAB\R2013a\',[4,18:20])
Ouputs *.txt files 4, 18, 19, and 20 from the R2013a folder (and any subfolders) of the MATLAB program files.
________________________________________
NOTES :
-Supplying a directory will add that directory to the current working directory
-Filename endings can also be provided to narrow search example: '*sample.csv' will output all files ending in sample.csv)
-Use UIGETDIR to interactively get directory path and pass it to GETFILES
-The first files in the list will generally be the files from the main folder selected
Cita come
Dan Nyren (2024). getfiles.m (https://www.mathworks.com/matlabcentral/fileexchange/47459-getfiles-m), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
Tag
Riconoscimenti
Ispirato: Find duplicate files
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.