moving files from one directory to multiple folders
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello all,
I am a first-time poster, long-time reader. I am also new to Matlab.
I have multiple files in one directory. The file names are date_specimen_experiment001xy01.tif. The experiment number changes with a max of 720 (_experiment001xy01,_experiment002xy01,etc). The xy position change with a max of 10 (_experiment001xy01,_experiment001xy02,etc). I want to move files (_experiment001xy01 to _experiment001xy10) into folder 1. I then want to sequentially do this for all 720 experiments. The end product should be 720 folders with 10 files in each folder.
0 comentarios
Respuestas (1)
Image Analyst
el 30 de Jun. de 2016
Try something like
inputFile = '_experiment001xy01.tif';
[inputFolder, baseFileName, ext] = fileparts(inputFile)
exptNum = str2double(baseFileName(12:14))
outputFolder = fullfile(inputFolder, num2str(exptNum))
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
destinationFile = fullfile(outputFolder, baseFileName);
copyfile(inputFile, destinationFile);
repeat for all files using code from the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
0 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!