endef 1.0.1 → 1.0.3
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 +2 -3
- package/src/de.sh +39 -36
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "endef",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Encrypt or Decrypt Files Test",
|
|
5
5
|
"bin": {
|
|
6
|
-
"endef": "bin/main.js"
|
|
7
|
-
"endeftest": "bin/main.js"
|
|
6
|
+
"endef": "bin/main.js"
|
|
8
7
|
},
|
|
9
8
|
"scripts": {
|
|
10
9
|
"prettier": "prettier --write \"**/*.{js,jsx,ts,json,vue,css,less,scss,md,html}\""
|
package/src/de.sh
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
if ! [[ $filename =~ \._\$_foobar ]]; then
|
|
16
|
+
echo "Skipping file: $file"
|
|
17
|
+
continue
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# 移除后缀
|
|
21
|
+
new_filename=${filename%%._$_foobar*}
|
|
22
|
+
|
|
23
|
+
# 构建新的文件路径
|
|
24
|
+
new_file="$dir/$new_filename"
|
|
25
|
+
|
|
26
|
+
# 重命名文件
|
|
27
|
+
mv "$file" "$new_file"
|
|
28
|
+
|
|
29
|
+
echo "File renamed: $new_file"
|
|
30
|
+
done < <(find "$directory" -type f \( -name ".*" -o -empty \) -print0)
|
|
31
|
+
|
|
32
|
+
# 递归处理子目录
|
|
33
|
+
find "$directory" -mindepth 1 -maxdepth 1 -type d -not -name ".*" -print0 | while IFS= read -r -d '' subdir; do
|
|
34
|
+
remove_suffix "$subdir"
|
|
35
|
+
done
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
directory="$DIR" # 替换为你的目录路径
|
|
39
|
+
|
|
37
40
|
remove_suffix "$directory"
|