How to copy a selective list of files, 'b', 'c' and 'd', from folder A to the folders 'B', 'C' and 'D' respectively.

2 Ansichten (letzte 30 Tage)
How to copy a selective list of files, 'b', 'c' and 'd', from folder A to the folders 'B', 'C' and 'D' respectively. Furthermore, I have an additional distinct question. How to open a '.bat' file with the Matlab command and with no further action to be performed in Matlab.

Akzeptierte Antwort

Rik
Rik am 18 Aug. 2018
If you have the list of files and target folders, you can use the copyfile function. Running a batch file is as easy as doing this:
example='C:\batch_file.bat';
%example='batch_file.bat';%if the file is in the current folder
%example='C:\folder with space\batch_file.bat';
system(sprintf('"%s"',example));
You can also start it as a parallel process:
system(sprintf('start "%s"',example));
  5 Kommentare
sagar
sagar am 21 Aug. 2018
Bearbeitet: sagar am 21 Aug. 2018
Thanks once again for the solution. It will nice if could you show one example with the necessary syntax. i.e. extracting the timestamp of different files, comparing it and then further copying the file to different folder based on the comparison of the dates.
Rik
Rik am 21 Aug. 2018
Why don't you try something, and if that fails, explain what you tried, and what the exact rules for your comparison and copy are. I could write an example for you, but it will likely be totally irrelevant for your use case. You know the function you need to use: dir. It returns a struct with several fields. You should be able to write some kind of loop that deals with these files.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

sagar
sagar am 20 Aug. 2018
Sorry Friend, for the delayed response. My bad. Regarding the solution to the problem both the suggestions worked fine. Thanks a lot. Have a nice time ahead.

Kategorien

Mehr zu Environment and Settings 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