How to use system to copy binary files which are not in the current directory

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.

 채택된 답변

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

Hi Geoff, thanks for the quick response. I tried appending the code as you suggested but the console returns a syntax error. Do you have any other suggestions?
Thanks again.
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 =)
Thanks Geoff this works perfectly!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

질문:

2012년 3월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by