Perl Script – Look For Word – Move Files

Hello,

I need a perl script to run on a Linux box (Ubuntu) that can do this:

1. Scan this folder /DMDS/1.Share for all *id files

2. Look within each *id file for a word

That word should be something I should be able to set in a configuration file.

For example a word it should look for: DMDS-WWW-NCK

3. If that word is found it should move that file to: /DMDS/2.Send-this/

That file will have a filename of %year%-%month%-%day%-%hour%-%minute%-%second%.id

Then also a *rar and a *mvg file exists with the exact same name except the extension – and I want the script to move these files also:

So all in all the files to move are:

%year%-%month%-%day%-%hour%-%minute%-%second%.id
%year%-%month%-%day%-%hour%-%minute%-%second%.mvg
%year%-%month%-%day%-%hour%-%minute%-%second%.rar

Moved to: /DMDS/2.Send-this/

4. Last step is to call my sript: /DMDS/0.Tasks/send-files.sh

5. Script should log what it is doing – and I want the script to run as a daemon and check for new files each minute.

Thanks for help,

Best regards,
Johan

Leave a Reply

Your email address will not be published. Required fields are marked *