-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsos.sh
executable file
·38 lines (28 loc) · 912 Bytes
/
sos.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
#!/bin/bash
#set -x
mulu="动漫/大王不高兴/S02/"
del_name="大王不高兴 S02E"
#获取当前脚本目录copy脚本之家
Source="$0"
while [[ -h "$Source" ]]; do
dir_file="$( cd -P "$( dirname "$Source" )" && pwd )"
Source="$(readlink "$Source")"
[[ $Source != /* ]] && Source="$dir_file/$Source"
done
dir_file="$( cd -P "$( dirname "$Source" )" && pwd )"
ls $dir_file/$mulu | grep -v ".sh" > /tmp/old.txt
ls $dir_file/$mulu | grep -v ".sh" > /tmp/new.txt
sed -i "s/$del_name//g" /tmp/new.txt
old_num=$(cat /tmp/old.txt | wc -l)
new_num=$(cat /tmp/new.txt | wc -l)
num="1"
while [[ `expr $new_num + 1 ` -gt "$num" ]];do
for i in `cat /tmp/new.txt`
do
old_name=$(cat /tmp/old.txt | awk -v a="$num" 'NR==a{print $0}')
echo " 【$old_name】 重命名 $i"
mv "$dir_file/$mulu$old_name" "$dir_file/$mulu$i"
num=$(expr $num + 1)
done
done
echo "替换完成"