How to move indexed files say file_1, file_2, file_3 to indexed folder_1, folder_2, folder 3. I am using for loop to create these folders and files in an indexed and automatic manner.....but how to move these files into these folders...Plz help
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shadman khan
am 7 Dez. 2019
Kommentiert: shadman khan
am 8 Dez. 2019
FileBaseName='MyDataFile_' %set file base name Mydatafile
FolderBaseName='Case_' %set folder base name case_
parameter=[1 12] %using these array values, CONTENT of each CASE file is written
for i=1:length(parameter)
filename=[FileBaseName,num2str(i)] %indexed filenames
folderName=[FolderBaseName,num2str(i)] %indexed foldernames
mkdir([FolderBaseName,num2str(i)]) % make folder first
fileID = fopen(filename,'w'); %open file for writing
THC=parameter(i) %choose parameter value for writing
fprintf(fileID, 'chosen value is %2.2f', THC); %write the content to file
fclose(fileID) %close the file
% for j=1:1:length(parameter)
% move CASE1 TO FOLDER1 (BUT HOW ??)
%I TRIED USING MOVEFILE but its not working
%END
end
0 Kommentare
Akzeptierte Antwort
Matt J
am 8 Dez. 2019
>> Files="file_"+(1:5)
Files =
1×5 string array
"file_1" "file_2" "file_3" "file_4" "file_5"
>> Folders="folder_"+(1:5)
Folders =
1×5 string array
"folder_1" "folder_2" "folder_3" "folder_4" "folder_5"
>> for i=1:5, movefile(Files{i},Folders{i}); end
1 Kommentar
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!