Change directories within a loop
Show older comments
Currently my code looks like this
location='/pathtodata';
copyfile('location','./.')
It keeps trying to copy all folders named location into my directory, not folders from my previously defined location. I am using this in a loop so I want to be able to define the location of the data separately before putting it into my copy file code.
How do I get these files to copy?
1 Comment
Walter Roberson
on 10 Nov 2016
Could you confirm that you want to copy folders literally named 'location' ? If so, then what role does your variable that happens to be named location play here?
You want to do that multiple times in a loop? Are the previous location folder that was copied to be removed, or do you want to merge all of the contents into one big directory, or do you want to rename as you go so they end up with separate names like location_0001 location_0002 ?
Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!