Effacer les filtres
Effacer les filtres

Script to transfer files from a folder based on a trigger

4 vues (au cours des 30 derniers jours)
fadzhi
fadzhi le 18 Jan 2021
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 commentaire
Mario Malic
Mario Malic le 18 Jan 2021
There are many questions that are same as yours, use search tool to find your answer.

Connectez-vous pour commenter.

Réponses (1)

Manas Shukla
Manas Shukla le 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)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by