I'm trying to have matlab copy a file, but change the name in the process. I believe I'm doing it exactly as i should, but I'm not getting the expected results. I'll try to be as detailed as possible.
I have a folder called modes that has a bunch of .png files in it. All the files are named something like 001_mode1234.png etc. Each one is unique. I want to copy a specific one of these files, move it up a folder, and rename it "runmode.png". So the code looks something like this:
indexmode = 1234 name = strcat('*_mode',num2str(indexmode),'.png'); cd modes/ copyfile(name,'../runmode.png') cd ..
Now the result I'm getting is that in the main folder where the file should be copied to, instead of being renamed to "runmode.png" it is creating a folder called "runmode.png" and placing the image file (still named "001_mode1234.png") inside this folder.
I have tried using movefile, as well as tried copyfile(name,'runmode.png') to keep it in the same directory and both result in the same thing. Am I doing something wrong? Or is this possibly a bug? In case it matters I'm running matlab2012a on ubuntu 10.04
Best Answer