LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with script that moves files under a day into another folder. (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-script-that-moves-files-under-a-day-into-another-folder-770517/)

nate_is_cool 11-20-2009 05:46 PM

Problem with script that moves files under a day into another folder.
 
I'm in the making of a Video surveillance system and the program I am using makes each video into a couple of seconds long. Now I'm in the making of a script that will compile them all together but am having some trouble with the "find" command. I want it to move only files under a day, as in all the files created that day into a folder, which will then be compiled. Problem is when I run the script it copies EVERYTHING into the folder and not just things created in the last 12 hours or so. Heres what I have so far.

cd "/home/administrator/Desktop/Feed/cam1"
mkdir temp
find "/home/administrator/Desktop/Feed/cam1" -ctime -.05 -exec mv *.avi /temp {} \;
cd temp
mencoder *.avi -noidx -o temp.avi -ovc copy
cp temp.avi "/home/administrator/Desktop/Feed/cam1"
rm *.avi
cd "/home/administrator/Desktop/Feed/cam1"
rm -r temp
mv temp.avi `date '+%m-%d-%y'`.avi

I'm guessing it's something with the "find "/home/administrator/Desktop/Feed/cam1" -ctime -.05 -exec mv *.avi /temp {} \;" part.

If im doing it all wrong then heres what I would like: At about 10-11PM I want it to take all the videos and compile them into one for the day then name it based on what day it is.So when I go to look what happened on EX: November 18th I can go into the /cam1 directory and see a movie name 11-18-2009. At the moment I have about 50 videos per day.

Im using Ubuntu 9.04. I've been working at this for a few hours now but I'm not really going anywhere. Any ideas?

-Thanks Nate

berbae 11-21-2009 04:42 AM

I think
Code:

find . -name "*.avi" -ctime -1 -exec mv {} ./temp \;
would be syntaxically more correct.

. stands for the current directory.

Read carefully the find manual.
Quote:

-n for less than n,
...
-ctime n
File's status was last changed n*24 hours ago.
...
The string `{}' is replaced by the current file name being processed ...
Before executing the move command, you can test the result of the find command with :
Code:

find . -name "*.avi" -ctime -1 -exec ls -l {} \;
to see if the number for the ctime filter is right, and change it until you get what you want.

Greetings.

Smartpatrol 11-21-2009 07:25 AM

...


All times are GMT -5. The time now is 05:41 AM.