cp | greb


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp | greb
# 1  
Old 07-08-2012
cp | greb

Hi guys,

First of all thanks for reading this and the already provided information! I was reading about a post that was created a couple of years back:

86686-ls-l-all-files-created-between-two-times.html (i am not allowed to copy urls Smilie )

My question is somehow similar.

I have a directory with +/- 68.000 photos (JPEG images) that where created from 15-01-2012 until 04-06-2012. The photos where created every 2 minutes. There are some gaps in between but that is not important.

From these 68.000 file I am only interested in the once that where created between: 09:00 and 17:30

In other words: I need a specific filter within the data filter, correct?

How does the syntax look like for the cp command, if I want to copy the selected query to another directory?

Many, many thanks,

Paul
# 2  
Old 07-08-2012
Is the time of making the photo part of the filename?
# 3  
Old 07-08-2012
Quote:
Originally Posted by bartus11
Is the time of making the photo part of the filename?
Nope. File name is sequential 1,2,3,4....68151.jpg

Only time is the time stamp.

Thanks.
# 4  
Old 07-08-2012
Check if this gives you files that should be copied:
Code:
stat -c "%y %n" * | awk -F"[ :]" '$2>=9&&$2<17||$2==17&&$3<=30{print $6}'

# 5  
Old 07-08-2012
Quote:
Originally Posted by bartus11
Check if this gives you files that should be copied:
Code:
stat -c "%y %n" * | awk -F"[ :]" '$2>=9&&$2<17||$2==17&&$3<=30{print $6}'

aah Smilie

Can you explain what is happening here?
# 6  
Old 07-08-2012
statis used to read file's modification date and awk is used to filter files that were modified between 9:00 and 17:30. If this code gives you proper results, then you can copy those files using:
Code:
stat -c "%y %n" * | awk -F"[ :]" '$2>=9&&$2<17||$2==17&&$3<=30{print $6}' | xargs -i cp {} /somewhere/else

This User Gave Thanks to bartus11 For This Post:
# 7  
Old 07-08-2012
I forget to mention:

I am running a Mac os X machine with Debian Linux. Don't think the -c command is working?
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question