Hello,
I have a Linux server where I need a script that can do this.
1.
At random times I have new files arriving (uploaded) into a folder /Share/[login to view URL]
The files that arrive there are always three files then a fourth trigger file that is uploaded lastly ([login to view URL]) (that marks that the upload is complete).
/Share/[login to view URL]
/Share/[login to view URL]
/Share/[login to view URL]
/Share/[login to view URL]
2.
Your script should scan this folder (/Share/[login to view URL]) and look for the file “[login to view URL]”
• I plan to schedule (cron) your script to be run say each 5th minute and look inside this folder and see if the trigger file exists ([login to view URL]).
• If trigger file exists your script should continue – otherwise abort.
3.
Process new files – if [login to view URL] file is found
• If the file “[login to view URL]” exists I want your script to continue and then to look inside this file:
/Share/[login to view URL]
Inside that file there is name of the format “DMDS-LNX-0001”.
The name inside this file is random.
Save this name into a variable.
4.
Next your script should look inside the folder: /Share/[login to view URL]
Scan all files with the names /Share/[login to view URL]*.id and see if the same variable name exists.
If it exists I want these files to be removed:
/Share/[login to view URL]%year-month-day-hour-minue-second%.id
/Share/[login to view URL]%year-month-day-hour-minue-second%.mvg
/Share/[login to view URL]%year-month-day-hour-minue-second%.rar
All updates have three files and I want all these three files to be removed – so a duplicate update don't exists.
There might be many files inside this folder – so your script should be able to process a lot of files.
5.
Once files are removed you can move the new files from /Share/[login to view URL] to /Share/[login to view URL]
• Files to move are those three new files:
/Share/[login to view URL]
/Share/[login to view URL]
/Share/[login to view URL]
But you can delete the [login to view URL] file (/Share/[login to view URL])
6.
Sometimes duplicate files wont exists then your script can just move the files from:
/Share/[login to view URL]
/Share/[login to view URL]
/Share/[login to view URL]
To:
/Share/[login to view URL]%year-month-day-hour-minue-second%.id
/Share/[login to view URL]%year-month-day-hour-minue-second%.mvg
/Share/[login to view URL]%year-month-day-hour-minue-second%.rar
7.
Sometimes whitespace exists within the files:
/Share/[login to view URL]
/Share/[login to view URL]
You script should see to it that this whitespace is removed – before moving the files from /Share/[login to view URL] to /Share/[login to view URL]
8.
I want your script to write to a log file on what it's doing.
And I should be able to change some paths in the script if folder structure might change in the future.
I prefer if the script is made with either PHP or Perl.