Find Files Script – And Move/extract Them

Hello,

I need help creating a script – that should run on a Linux server.
Script can be done with either pearl or .php.

1.Step 1

Check if any files exist:
For example:
/mnt/wwwroot/Group-%/6.UploadArea/*
/mnt/wwwroot/Group-%/6.UploadArea/*
/mnt/wwwroot/Group-%/6.UploadArea/*
/mnt/wwwroot/Group-%/6.UploadArea/*

– Check for files at location: /mnt/wwwroot/Group-%/6.UploadArea/*.zip files or /mnt/wwwroot/Group-%/6.UploadArea/.* files

– The % is a number between 1 to 99 – some folders exists and some do not.

2. Step 2

-If a .zip file is found here: /mnt/wwwroot/Group-%/6.UploadArea/*.zip
– Extract the content of the zip to /mnt/wwwroot/Group-%/encode-this/
– And then remove the /mnt/wwwroot/Group-%/6.UploadArea/*.zip
– There could be more than one file – so process one file at a time.
– Also echo out the “group name” to > /mnt/wwwroot/Group-%/encode-this/group-%.mvg which is the folder name from where the file where found.

3. Step 3.

– If a .* file is found here: /mnt/wwwroot/Group-%/6.UploadArea/.*

– The file found here has a random name but they all begin with a dot: . Then after the . there are some random numbers.

– A corresponding file under /mnt/wwwroot/Group-%/6.UploadArea/stage/.* is found here (this file is a zip).

– The last letter in the filename can be a little different but the first letters are the same.

– For example:
/mnt/wwwroot/Group-%/6.UploadArea/.19809265 if found here then this file exists: /mnt/wwwroot/Group-%/6.UploadArea/.19809265/stage/.19809265.0
Basically the file: /mnt/wwwroot/Group-%/6.UploadArea/.19809265 is only a trigger that show that this file exists: /mnt/wwwroot/Group-%/6.UploadArea/.19809265/stage/.19809265.0

-Then I want this file (that is a .zip): /mnt/wwwroot/Group-%/6.UploadArea/.19809265/stage/.19809265.0 to be extracted to: /mnt/wwwroot/Group-%/encode-this/
Then remove the /mnt/wwwroot/Group-%/6.UploadArea/.19809265/stage/.19809265.0 and the trigger file /mnt/wwwroot/Group-%/6.UploadArea/.19809265

-There could be more than one file here so process each file at a time.

– Also echo out the “group name” to > /mnt/wwwroot/Group-%/encode-this/group-%.mvg which is the folder name from where the file where found.

4. Step 4.

Also log everything to a .log file so i can see what happens.

Thanks for help,

Best regards,
Johan

Leave a Reply

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