-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_remove.sh
executable file
·48 lines (44 loc) · 1.09 KB
/
file_remove.sh
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
#!/bin/bash
# sourcing environment.sh will not work in non-interactive bash,
# you have to specify the path of this script in these cases.
if [ $# == 0 ]; then
echo "mv: missing file operand"
exit -250
fi
declare -a inputs=( $@ )
trash_personal="${HOME}/Trash_Personal"
trash_system="${HOME}/.local/share/Trash/files"
if [ -d ${trash_personal} ]; then
trash_folder=${trash_personal}
elif [ -d ${trash_system} ]; then
trash_folder=${trash_system}
else
echo "Trash folder not located correctly."
echo "To unalias, use command: unalias rm"
exit -250
fi
year=`date +%Y`
month=`date +%m`
day=`date +%d`
trash_sub1="${trash_folder}/${year}-${month}-${day}"
if [ ! -d ${trash_sub1} ]; then
mkdir ${trash_sub1}
fi
hour=`date +%H`
trash_sub2="${trash_sub1}/H${hour}"
if [ ! -d ${trash_sub2} ]; then
mkdir ${trash_sub2}
fi
min=`date +%M`
sec=`date +%S`
trash_sub3="${trash_sub2}/M${min}:S${sec}"
if [ ! -d ${trash_sub3} ]; then
mkdir ${trash_sub3}
fi
i=0
while [ $i -lt $# ]; do
if [ ${inputs[i]} != "-r" ]; then
mv ${inputs[i]} ${trash_sub3}
fi
i=$[$i+1]
done