0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/bash
prefix=$HOME"/crypthome"
pictures=(bmp jpg jpeg pgm rgb tga png gif ico)
docs=(rtf doc docx pdf txt)
html=(shtml html xml css htm xhtml xslt xls)
audio=(mp3 mp4 mpeg flv 3gp webm)
arch=(zip rar gz bz2 tar 7zip ar tar\.gz tar\.bz2 xz 7z)
pack=(deb rpm jar)
scripts=(sh pl py php js cpp c sql)
conf=(conf cfg)
torrent=(torrent)
an=""
mdt=""
function get_date
{
dt=`date`
pt1=${dt:4:7}
pt1=`echo $pt1 | tr [:space:] _`
echo $pt1
pt2=${dt:25:25}
echo $pt2
mdt=$pt1$pt2
echo $mdt
}
function recogn
{
recogn_arr=("$@")
for fname in ${recogn_arr[@]} ; do
if [ -f $fnm ]; then
rslt=`echo $an" "$fnm | grep -i \.$fname$`;
if [ -n "$rslt" ]
then
echo $rslt
if [ -d $prefix"/"$an ]; then
echo "dir" | ls -l $prefix"/"$an
cd $prefix"/"$an
pwd
else
mkdir $prefix"/"$an
fi
pc="Pictures"
if [[ $an == "Pictures" ]]; then
get_date
if [ -d $prefix"/"$an"/"$mdt ]; then
echo $prefix"/"$an"/"$mdt"/" | xargs -I {} mv $fnm {}
exit 1
else
mkdir -p $prefix"/"$an"/"$mdt
echo $prefix"/"$an"/"$mdt"/" | xargs -I {} mv $fnm {}
exit 1
fi
fi
echo $prefix"/"$an"/" | xargs -I {} mv $fnm {}
fi
else
echo "No file"
exit 1
fi
done
}
fnm=`find $1 -amin -1 | grep $2$`
echo $fnm
an="Pictures"
recogn "${pictures[@]}"
an="books"
recogn "${docs[@]}"
an="Downloads"
recogn "${html[@]}"
an="music"
recogn "${audio[@]}"
an="arch"
recogn "${arch[@]}"
an="pack"
recogn "${pack[@]}"
an="src"
recogn "${scripts[@]}"
an="conf"
recogn "${conf[@]}"
an="torrent"
recogn "${torrent[@]}"
Копирует файлы с определенным расширением в соответствующую директорию.
Запостил:
AliceGoth ,
21.06.2012 (Updated 25.03.2018 )
Комментарии (4) RSS