Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-20-2009, 05:46 PM   #1
LQ Newbie
Registered: Nov 2009
Posts: 3

Rep: Reputation: 0
Exclamation 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
Old 11-21-2009, 04:42 AM   #2
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
I think
find . -name "*.avi" -ctime -1 -exec mv {} ./temp \;
would be syntaxically more correct.

. stands for the current directory.

Read carefully the find manual.
-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 :
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.

Old 11-21-2009, 07:25 AM   #3
Registered: Sep 2009
Posts: 196

Rep: Reputation: 38

Last edited by Smartpatrol; 03-11-2010 at 09:48 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script that moves X number of files guest Programming 3 12-14-2008 03:34 AM
Script to delete files from specified folder mrrx7 Solaris / OpenSolaris 4 08-27-2007 03:50 AM
bash script, for all files in folder do ............ Simon_6162 Programming 2 07-18-2007 02:40 PM
Script that checks for new files in a folder achtung_linux Programming 7 02-03-2007 09:18 AM
How to copy in a script files to a samba folder? Julianus Linux - Networking 1 10-09-2004 07:29 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration