Filter löschen
Filter löschen

Script to transfer files from a folder based on a trigger

4 Ansichten (letzte 30 Tage)
fadzhi
fadzhi am 18 Jan. 2021
Beantwortet: Manas Shukla am 10 Mai 2022
Hi all,
For the problem below, i think the best solution is some bat script but i wanted to do this is Matlab. is it possible to write a script to achieve below:
Folder A, Folder B and Folder C
Folder C has 100 files marked as txt_1 to txt_100, whenever Folder A has a new file (i am using python to trigger a matlab code that outputs in A)
One file (txt_1) from Folder C should be copied to Folder B ....(for second new file in A, move txt_2 and so on....)
Many thanks in advance
Regards,
  1 Kommentar
Mario Malic
Mario Malic am 18 Jan. 2021
There are many questions that are same as yours, use search tool to find your answer.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Manas Shukla
Manas Shukla am 10 Mai 2022
As per my understanding of your issue, there are three folders, lest say Folder A, Folder B and Folder C. You want to write a MATLAB script which will copy a file from Folder C, in a systematic order, and paste it into Folder B whenever a new file is added in Folder A. You are using some Python code as trigger. I will bifurcate the workaround.
The first part is to check whether a new file is added to Folder A or not. For this you can refer to the below linked ML Answers Post. Detect New File in a Directory - (mathworks.com)
The second part is to copy a file from Folder C to Folder B. For that you can use the 'copyfile' command. Refer to the below example.
copyfile txt_1 'Folder B'
This will copy a file name 'txt_1' from current folder (i.e. Folder C) and paste it into Folder B. Link to 'copyfile' documentation is also attached here for your reference. Copy file or folder - MATLAB copyfile (mathworks.com)

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by