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

3 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Geoff
Geoff il 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 Commenti
Geoff
Geoff il 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 =)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by