How do I move files from current directory to a subfolder?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm a new matlab user so apologies. I want to move files from my current directory to a subfolder.
The filenames are structured as follows
Y1_ANN1.ext, Y1_ANN2.ext....,Y10_ANN10.ext
I have set the current directory to that in which the files are currently located.
The destination folder is sub-folder two levels below the current directory.
This is what I have done so far but for some reason it doesn't seem to be working (I will be looping through values of j and k but just want it to work for the first file first). I keep on getting an error message that the file doesn't exist. I have checked the cd and it is correct and I have checked that 'namefile' is in the cd but it still isn't working. Any ideas? Thanks.
clear all
allsubj = { 'Y1'};
blocks = {[1:4] };
anndatafolder=sprintf('%s/%s',parentFolder, annulusFolder);
for j=1
for k=1
part=strcat('Y',num2str(j));
block=strcat('_ANN',num2str(k));
namefile = sprintf('%s%s%s',part,block,'.bdf');
newloc=sprintf('%s/%s/%s', anndatafolder,part,'XXX')
cd=anndatafolder
movefile(namefile,newloc);
end
end
0 Kommentare
Antworten (1)
Walter Roberson
am 17 Jan. 2014
cd=anndatafolder sets a variable named "cd" to the contents of "anndatafolder".
cd(anndatafolder)
would change directories using the content of "anndatafolder" as the name of the directory.
Note that the cd() only needs to be done once before the "for j" loop.
Siehe auch
Kategorien
Mehr zu Search Path 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!