T4K3D0WN
(usa Ubuntu)
Enviado em 25/05/2015 - 17:47h
ta ai mais ele ta com erro '-' as vezes funciona as vezess n ;-;
#!/bin/bash
# -*- coding: utf-8 -*-
#
# script.sh
#
# Copyright 2015 takedown <keneth.handerson@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
#variaveis
foldern="-1";
diminui="10000";
folderprefix="dvd_";
dvdvalue="3850240";
files="$(tac .list.txt 2>/dev/null)";
temp="";
mkdir -p arquivos_grandes
#listar
function listar(){
echo "">.list1.txt
ls -s *mp4 *mp3 *avi *.ogg *flv *wmv *mkv *3gp *webm *vob 1>>.list1.txt 2>/dev/null
sed '/total/d' .list1.txt 1>/dev/null 2>/dev/null
sed 's/ /:/g' .list1.txt 1>.list.txt 2>/dev/null
}
#adiciona +1 ao nome da pasta
function more1(){
foldern="$( echo $foldern +1 |bc)"; }
#chama a funcao e cria a pasta
function mk(){
more1
mkdir -p $folderprefix$foldern
}
#loop inicial
function loop1(){
resulta="$(cat .list.txt |grep $valuet)";
resultb="$(cat .list.txt |grep $valuet|sed 's/ /:/g'|awk -F: '{print $2" "$3" "$4""$5""$6""$7""$8""}')";
}
function loop2(){
if [ $resulta -lt $valuet ]
then
mv *$(echo $resultb|sed 's/:/*/g') $folderprefix$foldern
else
value2="$(echo $valuet - $diminui |bc)";
valuet=value2;
loop1
loop2
fi
}
listar #chama o listamento
#executa o loop para cada arquivo da lista
for file in $files
do
temp="$(echo $file|awk -F: '{print $1}')";
selecionado="$(echo $file |cut -c 10-)";
if [ $temp -gt $dvdvalue ]
then
#notifica e move arquivos grandes
notify-send "o arquivo '$(echo $file|awk -F: '{print $2" "$3" "$4""$5""$6""$7""$8""}')' e grande d+ movendo para pasta separada" --icon=/usr/share/icons/Humanity/apps/64/bash.svg
mv *$(echo $selecionado|sed 's/:/*/g') arquivos_grandes
else
#cria a pasta e move arquivos para ela
mk
mv *$(echo $selecionado|sed 's/:/*/g') $folderprefix$foldern
value="$(echo $dvdvalue - $temp |bc)";
valuet="$(echo $value |cut -c 1-5)";
#inicia o loop
loop1
loop2
fi
if listar
then
null2="1"
fi
done