Borrar filtros
Borrar filtros

Can't copy files using the DOS() command in MATLAB

1 visualización (últimos 30 días)
Hugo
Hugo el 9 de Mayo de 2022
Comentada: Jan el 9 de Mayo de 2022
I am trying to copy an external file a.txt to a new file, named b.txt, by using the following code:
command='COPY C:\text\a.txt C:\text\b.txt '
dos(command)
However, this code does not create the expected file b.txt. I already setup all the folders of the C: drive to be owned by my account (administrator), but that does not seem to work. Any suggestions on these would be appreciated.
Thank you,
  3 comentarios
dpb
dpb el 9 de Mayo de 2022
Use system instead of dos altho that's probably not the real problem.
Use
[status,cmdout]=system(cmd)
to see what actually happened. Quite possibly the file and/or folder don't exist.
Jan
Jan el 9 de Mayo de 2022
@Hugo: Do you get an error message? E.g. using dpb's suggestion should show one.
Using copyfile as suggested by Fangjun Jiang is smart also.
What happens if you run this in a command windows of the operating system?
"I already setup all the folders of the C: drive to be owned by my account (administrator), but that does not seem to work." - Really? This would be a really bad idea. On one hand working as admin has severe drawbacks: you can e.g. destroy Matlab toolbox files, which is impossible without admin privilegs. On the other hand many folders on C:\Windows should not even have Admin access for security reasons. Only the the System account should be able to access these folders.
Finally working on the root level of the C disk is a bad programming habit also. This was ugly in Windos 3.1 booted from a disk already and is not smarter in Windows 11.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by