moving files from one directory to multiple folders
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2016 年 6 月 30 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!