Page 1 of 1

[Linux] moving avi-files

Posted: March 12th, 2009, 9:49 pm
by Laat
Moves all avi-files, except filenames containing "sample"

Code: Select all

#!/bin/bash
cd "$1"

FILES=`ls *.avi | grep -iv sample`
echo "moving avi files..."
echo $FILES

a=0;
F_ARRAY=( $FILES )
for file in $FILES
do
        mv ${F_ARRAY[$a]} ~/downloads/extracted/
        (( a += 1 ))
done
exit 0
I get a nice "buffer" when removing one week old files from that folder with a cronjob.

Edit:
I delete old files and folders with this command:

Code: Select all

find /path/to/folder -depth -mindepth 1 -ctime +7 -delete

Re: [Linux] moving avi-files

Posted: March 17th, 2012, 6:18 pm
by hibbs
is there a way to edit this to also add support to move mp4's and mkv's as well please?

EDIT: Nevermind i think i got it under control now.....

Code: Select all

#!/bin/bash
cd "$1"

FILES=`ls *.avi *.mp4 *.mkv | grep -iv sample`
echo "moving avi files..."
echo $FILES

a=0;
F_ARRAY=( $FILES )
for file in $FILES
do
        mv ${F_ARRAY[$a]} /leech/files
        (( a += 1 ))
done
exit 0