Script to transfer files from a folder based on a trigger

2 visualizaciones (últimos 30 días)
fadzhi
fadzhi el 18 de En. de 2021
Respondida: Manas Shukla el 10 de Mayo de 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 comentario
Mario Malic
Mario Malic el 18 de En. de 2021
There are many questions that are same as yours, use search tool to find your answer.

Iniciar sesión para comentar.

Respuestas (1)

Manas Shukla
Manas Shukla el 10 de Mayo de 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)

Categorías

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

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by