-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganize.sh
More file actions
66 lines (49 loc) · 1.58 KB
/
organize.sh
File metadata and controls
66 lines (49 loc) · 1.58 KB
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
#!/bin/bash
origen="/var/lib/mldonkey/incoming/files"
destino="/data/share/organized"
#origen=` pwd `
#destino=${origen}_fecha
if [ ! -d $destino ] ; then
mkdir $destino
fi
ls $origen | wc -l
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in ` find $origen -type f -not -path "$origen/ShareOK/*" ` ; do
file=$(basename "$f")
base=${file%%.*}
e=${file##*.}
e=` echo $e | cut -d'_' -f 1`
nd=""
if [ $e == "doc" ] || [ $e == "DOC" ] || [ $e == "docx" ] || [ $e == "DOCX" ] || [ $e == "pdf" ] || [ $e == "PDF" ] || [ $e == "txt" ] || [ $e == "TXT" ] ; then
dir="docs"
else # image
cr_date=`exiftool -T -d '%Y%m%d' -createdate $f `
echo date $cr_date
if [ $cr_date == "-" ] ; then
nd="nodate/"
fi
dir=`exiftool -T -model -serialnumber $f `
dir="${dir// /_}"
dir="${dir//$'\t'/_}"
echo file: $f
echo exif_serial: $dir
if [ "$dir" == "-_-" ] ; then
echo "no serial $f"
# dir=` md5sum $f | awk '{print $1}' `
dir=` ed2k_hash $f | cut -d'|' -f5 `
dir=nocam/${dir}
echo Dir ed2k $dir
else
dir=cam/${dir}
fi
fi
dest=${destino}/${nd}${dir}
if [ ! -d "$dest" ] ; then
sudo mkdir --parents "$dest"
fi
dest=$dest/${base}.${e}
echo Destino: $dest
sudo mv "$f" "$dest"
done
IFS=$SAVEIFS