I have a system with a watch folder where people/companies can upload new files via FTP or SMB. In this watch folder They should ALWAYS upload 2 files: 1 media file with a prefix name of ABC*.mxf
and always a number for '*'. The other is the same file name, but with the .xml
extension.
example: uploaded files are: ABC0001.mxf, ABC0001.xml
if a second file ABC0002.xml is uploaded but the ABC0002.mxf is not yet uploaded, or not complete the ABC0002.xml file should NOT yet be moved. only when both ABC*.mxf and ABC*.xml have matchng names excist and are 5 min or older they should be moved.
I need to create a script that finds these 2 identical files (by name not extension) and only moves them if the modification time (mmin) is older than 5 minutes. So only completed files are moved.
Also I must say that multiple files can be uploaded at the same time by different suppliers. ABC0001.mxf + .xml by company 1, and ABC0100.mxf + .xml by company 2, and ABC1003.mxf + .xml by company 3. Not all finishing at the same times.
I already started with a partial script, but I'm struggling with the matching names part.
SOURCEDIR="/dir/to/source"
DESTDIR="/destination/dir"
for FOUND in `find $SOURCEDIR/AutoIngest -maxdepth 1 \
-type f -name ^ABC* -mmin +5 `;
do
mv "$FOUND" "$DESTDIR/"
done
EDIT: changed the file names from ABC* to ABC*.mxf because the media file always have the .mxf extension. And added a file upload example.