Complex File Move

Hello,
This is my first post, so please forgive my obvious lack of UNIX knowledge. I am trying/needing to write a script that follows this functional flow:

  1. Access a config file that contains format:
<directory> <filetype> <daterange> 
<directory> <filetype> <daterange> 
<directory> <filetype> <daterange> 
...

per row, with no limit on the number of rows.

  1. Copy these files meeting this criteria to a temp folder and zip them, using the current date/time as the zip file name.

This executable needs to be run daily at midnight (via crontab)?

Thank you for helping me solve this! :wink:

Please show a sample of the filenames, as well as how the date range is specified to help us understand how matching of names to date ranges and file types is done.

What I was thinking the config file would look like is something like this:

<directory> <filetype> <daterange>

so maybe an example would be like:

\markdir\ *.csv Feb 04 13:35
\markdir\ *.gz Jan 22 15:50
\markdir\ *.mdl Dec 14 2014
\markdir\ *.tlg Aug 01 2014
\markdir\ *.zdf Mar 05 2013

The dates are listed by mm dd hh:mm if in the current year, and mm dd yyyy if in the previous year. This makes it sort of complex I think. Thank you so much for your help!

---------- Post updated at 06:33 PM ---------- Previous update was at 06:20 PM ----------

I think I can be more clear with this, so let me try :slight_smile:

I need the script to run at 0700, and check multiple directories for newly created files. The directories to check, and extensions therein can be specified by the config file. If newly created files exist, then move them to a temp directory.

So I guess the config file really only needs the directory to look in, and the extension to check.

Example:

\markdir\ *.csv

So it will check \markdir\ to see if there are any file(s) whose creation date matches the current date.

Is that more clear? I hope I did not make more complexity.

The find command allows you to define the directory, file name(s), and a newer/older date to compare to. Sometimes you'll need to tweak its parameters a little.