List Info

Thread: date-specific cp/mv




date-specific cp/mv
user name
2006-09-28 16:16:44
Hi group,

I'd like to be able to cp or mv certain files from a
dir according to their timestamp.

man cp mentions the '--preserve' option but I don't
think that's what I need.

Does somebody know of some sort of script or perl or
python pass that'll do it?

-Maxim

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 
-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv
user name
2006-09-28 16:24:25
quoth the maxim wexler:
> Hi group,
>
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.

Have a look at find. You can whip up a one-liner using the
-atime, -mtime  
or -ctime tests (depending on your intent) and use -exec to
do the cp or 
mv...

> -Maxim

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10,
with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv
user name
2006-09-28 16:27:52
On 9/28/06, maxim wexler <blissfixyahoo.com> wrote:
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
>
> man cp mentions the '--preserve' option but I don't
> think that's what I need.
>
> Does somebody know of some sort of script or perl or
> python pass that'll do it?

something akin to:

find <srcdir> -type f -mmin 5 -exec cp {}
<destdir> ;

will copy all files in srcdir that have been modified within
5 minutes
to destdir.  check the find man page for other ways of
checking the
files or restricting how far find will recurse, etc..

-- 
Trey
-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv
user name
2006-09-28 16:41:57
I used to use this for moving old mail to an archive folder.
Just change the directories, and you should be golden.
alias archive='find ~/.maildir/inbox/cur -mtime +30 -exec mv
{} ~/.maildir/inbox/archive/cur/. ;'

Dave

On Thu, 28 Sep 2006 09:24:25 -0700
darren kirby <bulliverbadcomputer.org> wrote:

> quoth the maxim wexler:
> > Hi group,
> >
> > I'd like to be able to cp or mv certain files from
a
> > dir according to their timestamp.
> 
> Have a look at find. You can whip up a one-liner using
the -atime, -mtime  
> or -ctime tests (depending on your intent) and use
-exec to do the cp or 
> mv...
> 
> > -Maxim
> 
> -d
> -- 
> darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
> "...the number of UNIX installations has grown to
10, with more expected..."
> - Dennis Ritchie and Ken Thompson, June 1972
> -- 
> gentoo-usergentoo.org mailing list
> 


-- 
<Omnic> another .sig addition
date-specific cp/mv
user name
2006-09-28 16:47:52
On Thursday 28 September 2006 18:16, maxim wexler wrote:
> Hi group,
>
> I'd like to be able to cp or mv certain files from a
> dir according to their timestamp.
>
> man cp mentions the '--preserve' option but I don't
> think that's what I need.
>
> Does somebody know of some sort of script or perl or
> python pass that'll do it?

use find with the time-related options and -exec. To move 
everything in ~/mystuff that's older than 3 days (72 hours)
to 
~/backup, you could use

find ~/mystuff -type f -mtime 72 -exec mv {} ~/backup ;

find has many options related to searching by time (hours, 
minutes, etc) and you can select by atime, ctime or mtime.
It's 
all in the man page

alan
-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv
user name
2006-09-29 02:00:19
> find has many options related to searching by time
> (hours, 
> minutes, etc) and you can select by atime, ctime or
> mtime. It's 
> all in the man page

I can't get it to work. I used -ctime, -mtime, -mmin.
The files were created on the 26th of this month using
abcde. All the other files in the dir are at least two
weeks old, so I gave it 72(hours) then 3(days) to grab
everything in the last three days then 96 and 4 just
to make sure. I gave it mmin with 4810(72*60 minutes)
and 5760(90*60). Every time nothing happens; nothing
is copied and no error message is generated. I gave it
relative dirs and absolute dirs. I used -type f and
-fstype <file-type>. Nothing. 

-mw



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 
-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv
user name
2006-09-29 04:43:14
maxim wexler wrote:
>> find has many options related to searching by time
>> (hours, 
>> minutes, etc) and you can select by atime, ctime or
>> mtime. It's 
>> all in the man page
>>     
>
> I can't get it to work. I used -ctime, -mtime, -mmin.
> The files were created on the 26th of this month using
> abcde. All the other files in the dir are at least two
> weeks old, so I gave it 72(hours) then 3(days) to grab
> everything in the last three days then 96 and 4 just
> to make sure. I gave it mmin with 4810(72*60 minutes)
> and 5760(90*60). Every time nothing happens; nothing
> is copied and no error message is generated. I gave it
> relative dirs and absolute dirs. I used -type f and
> -fstype <file-type>. Nothing. 
>
> -mw
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
protection around 
> http://mail.yahoo.com 
>   
I believe the right syntax is:

find /path/dir -type f -ctime -3

This should mean "show all files created for the last 3
days".

Use  "-3" not "3"

-- 
Best regards,
Daniel


-- 
gentoo-usergentoo.org mailing list

date-specific cp/mv RESOLVED
user name
2006-09-29 16:34:49
> I believe the right syntax is:
> 
> find /path/dir -type f -ctime -3
> 
> This should mean "show all files created for the
> last 3 days".
> 
> Use  "-3" not "3"
> 

That's it 

-Maxim

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 
-- 
gentoo-usergentoo.org mailing list

[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )