endef 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/de.sh +33 -33
package/package.json
CHANGED
package/src/de.sh
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
DIR=$1
|
|
4
|
-
|
|
5
|
-
remove_suffix() {
|
|
6
|
-
local directory=$1
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
done
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
directory="$DIR" # 替换为你的目录路径
|
|
33
|
-
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
DIR=$1
|
|
4
|
+
|
|
5
|
+
remove_suffix() {
|
|
6
|
+
local directory=$1
|
|
7
|
+
|
|
8
|
+
# 使用 find 命令查找以 . 开头的文件
|
|
9
|
+
while IFS= read -r -d '' file; do
|
|
10
|
+
# 获取文件名和目录路径
|
|
11
|
+
filename=$(basename "$file")
|
|
12
|
+
dir=$(dirname "$file")
|
|
13
|
+
|
|
14
|
+
# 移除后缀
|
|
15
|
+
new_filename=${filename%%._$_foobar*}
|
|
16
|
+
|
|
17
|
+
# 构建新的文件路径
|
|
18
|
+
new_file="$dir/$new_filename"
|
|
19
|
+
|
|
20
|
+
# 重命名文件
|
|
21
|
+
mv "$file" "$new_file"
|
|
22
|
+
|
|
23
|
+
echo "File renamed: $new_file"
|
|
24
|
+
done < <(find "$directory" -type f \( -name ".*" -o -empty \) -print0)
|
|
25
|
+
|
|
26
|
+
# 递归处理子目录
|
|
27
|
+
find "$directory" -mindepth 1 -maxdepth 1 -type d -not -name ".*" -print0 | while IFS= read -r -d '' subdir; do
|
|
28
|
+
remove_suffix "$subdir"
|
|
29
|
+
done
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
directory="$DIR" # 替换为你的目录路径
|
|
33
|
+
|
|
34
34
|
remove_suffix "$directory"
|