Bash command to archive files daily based on date added
<p>I have a suite of scripts that involve downloading files from a remote server and then parsing them.  Each night, I would like to create an archive of the files downloaded that day.  </p>

<p>Some constraints are:</p>

<ul>
<li><p>Downloading from a Windows server to an Ubuntu server.</p></li>
<li><p>Inability to delete files on the remote server.</p></li>
<li><p>Require the date <em>added</em> to the local directory, <strong>not</strong> the date the file was created.</p></li>
<li><p>I have deduplication running at the downloading stage; however, (using ncftp), the check involves comparing the remote and local directories.  A strategy is to create a new folder each day, download files into it and then tar it sometime after midnight.  A problem arises in that the first scheduled download on the new day will grab ALL files on the remote server because the new local folder is empty.</p></li>
</ul>

<p>Because of the constraints, I considered simply archiving files based on "date added" to a central folder.  This works very well using a Mac because HFS+ stores extended metadata such as date created and date added.  So I can combine a tar command with something like below:</p>

<pre><code> mdls -name kMDItemFSName -name kMDItemDateAdded -raw *.xml | \ 
 xargs -0 -I {} echo {} | \ 
 sed 'N;s/\n/ /' | \
</code></pre>

<p>but there doesn't seem to be an analogue under linux (at least not with EXT4 that I am aware of).</p>

<p>I am open to any form of solution to get around doubling up files into a subsequent day.  The end result should be an archives directory full of tar.gz files looking something like: </p>

<pre><code>files_$(date +"%Y-%m-%d").tar.gz
</code></pre>