How to use system to copy binary files which are not in the current directory
6 views (last 30 days)
Show older comments
Hi,
I'm currently struggling with using the system command to combine a series of binary files into one file. My code (and therefore the current directory) is in: 'M:\Year 3\Programming and Software\MatLab' and the binary files I'm trying to combine are in 'M:\Project Action\Combine Test'.
My current attempt is stuck at the point seen in the code below.
system(['copy /b ' folder '/* ' folder '\' rename]);
Where 'folder' is the absolute location of the folder containing the binary files and 'rename' is a string to determine the name of the file containing all of the files combined.
Any help would be greatly appreciated :D
Thanks,
Jared.
0 Comments
Accepted Answer
Geoff
on 20 Mar 2012
Have you tried just doing this from the Windows command prompt?
I wasn't aware that the copy command would happily append files into a single one. Sounds like a dangerous feature to me.
Anyway, assuming it does, you need to quote your names:
system(['copy /b "' folder '\*" "' folder '\' rename '"']);
This way, the copy command will still recognise two arguments (source and destination) if the folder names contain spaces (which they do).
3 Comments
Geoff
on 20 Mar 2012
I had a mistake, which I fixed about 1 minute after I posted. Copy it and try again, in case you were too quick for me! If that fails, replace 'system' with 'display', and post the resulting output here. I'm going to bed, but I'm sure someone else can help if you're still stuck =)
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!