SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I don't really know how many files will be deleted and how long does it take (to find all), but in some cases executing that find two times looks not really efficient. Need to save the result of the first run (if speed is important) - and remove the collected files after the "Really delete" prompt.
That was my original idea, but I'm not certain on how to properly store the results from find and then safely delete them all (accounting for weird filename characters, etc).
*edit* I had looked at this, and it looks a bit wild to me.
So maybe if you want to avoid the double find call, this is a safe way:
Code:
readarray -d '' files < <(find $DIR -type f -maxdepth 1 -name "*.avi" -size -6M -print0)
printf '%s\n' "${files[@]}"
read -p "Really delete all? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -i "${files[@]}"
fi
This is specific to bash (>= 4.4), so -current only. Seems to work with strange characters in filenames, I'd test this though, hence the "rm -i" bit. Other people might know better ways though, I'm just looking at this for fun
Distribution: Slackware 15.0 x64, Slackware Live 15.0 x64
Posts: 621
Original Poster
Rep:
Thanks everyone, for all the suggestions.
Usually when I wake up and maybe once or twice throughout the day I'll go into the directory that has all the videos that caught 'motion' and look at them.
The videos that are 4MB and smaller usually will be a car going by relatively quickly (figure 5-10 mph, no faster as this is a trailer park and the main road runs right down the middle of us all, heh).
Other things like a cat or bird or bug, or a kid or two running to the bus stop, all usually are pretty quick and make a file of 4MB or smaller.
Anything larger I want to watch in MPlayer or whatever to make sure it isn't something that happened I want to know about or at least have the video to use as 'proof', etc.
So I've gone ahead and forgone the need to check anything 4MB and smaller and just use the first good script we came up with in this thread. If I let things go without checking for, let's say, 6 hours, there will be around 20-30 files and probably 10%-20% will be those I can delete without worry of looking at them. It takes time to watch what's leftover, if you figure a 9MB file lasts approximately 20 or 30 seconds and I have 20 to look through, heh.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.