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

2 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Geoff
Geoff am 20 Mär. 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 Kommentare
Geoff
Geoff am 20 Mär. 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 =)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by