[Wylug-discuss] Copy files by date

linux at sh2515.plus.com linux at sh2515.plus.com
Fri Jan 27 06:14:11 UTC 2012


> linux at sh2515.plus.com writes:
>
>> The date -v will not work because the version of date is old.
>
> Bah.

I know, blooming macs!

>
> What about the variant I gave which used Perl to calculate the date?
>
> If you need to install a Perl module, note you can do that as a normal
> user and put it under your home directory; you don't need to be root or
> install it system-wide.

I am sure it will work, but I don't know perl to finish off the rest of
the program.

I have used your date script and works great, so we now do it at the end
of the day.

I am now thinking about doing something that will put them in certain
folders to make it easier for people to get to.

today=$(date +%d-%m-%y)
for FILE in $(find . -iname '*.txt' -newermt $(date +%F) do;
if ($FILE='*AA*.txt)
then
mkdir ~/test/AA/$today
cp $FILE ~/test/AA/$today
else
if ($FILE=*BA*.txt)
then
mkdir ~/test/BA/$today
cp $FILE ~/test/BA/$today
.....
more of the same
.....
fi
fi

Is the syntax correct?
Also because there are a lot of files, would I be able to put xargs in
instead of cp, I am thinking no because it is a batch process rather than
running on each instance of $FILE through an if else if statement? could
be wrong, wife says I usually am.

Scott




More information about the Wylug-discuss mailing list