endef 1.0.3 → 1.0.5
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 +30 -34
- package/src/en.js +12 -12
package/package.json
CHANGED
package/src/de.sh
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
local
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
filename
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
if
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
# 处理文件名并重命名
|
|
4
|
+
process_filename() {
|
|
5
|
+
local file=$1
|
|
6
|
+
local filename=$(basename "$file")
|
|
7
|
+
local dir=$(dirname "$file")
|
|
8
|
+
|
|
9
|
+
# 判断文件名是否以指定字符串结尾
|
|
10
|
+
if [[ $filename =~ \._\$_foobar$ ]]; then
|
|
11
|
+
local new_filename=${filename%%._$_foobar*} # 移除指定字符串
|
|
12
|
+
local new_path="$dir/$new_filename" # 构建新的文件路径
|
|
13
|
+
|
|
14
|
+
# 判断新文件名对应的文件是否存在
|
|
15
|
+
if [[ -f "$new_path" ]]; then
|
|
16
|
+
if grep -q "E-SafeNet" "$new_path"; then
|
|
17
|
+
rm "$new_path" # 删除包含特定内容的文件
|
|
18
|
+
mv "$file" "$new_path" # 重命名文件
|
|
19
|
+
echo "Renamed: $filename -> $new_filename"
|
|
20
|
+
else
|
|
21
|
+
rm "$file" # 删除不包含特定内容的文件
|
|
22
|
+
echo "Deleted: $filename"
|
|
23
|
+
fi
|
|
18
24
|
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
|
|
25
|
+
fi
|
|
36
26
|
}
|
|
37
27
|
|
|
38
|
-
|
|
28
|
+
# 指定目标目录
|
|
29
|
+
directory="$1" # 替换为您的目录路径
|
|
30
|
+
|
|
31
|
+
# 导出函数以便在并行处理中使用
|
|
32
|
+
export -f process_filename
|
|
39
33
|
|
|
40
|
-
|
|
34
|
+
# 处理文件名并重命名(并行处理)
|
|
35
|
+
find "$directory" -type f -print0 | \
|
|
36
|
+
xargs -0 -P "$(nproc)" -I{} bash -c 'process_filename "$@"' _ {}
|
package/src/en.js
CHANGED
|
@@ -39,18 +39,18 @@ export default function processFiles(directory) {
|
|
|
39
39
|
console.log('Temp file written:', tempFilePath)
|
|
40
40
|
|
|
41
41
|
// 删除原文件
|
|
42
|
-
fs.unlink(filePath, err => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
42
|
+
// fs.unlink(filePath, err => {
|
|
43
|
+
// if (err) {
|
|
44
|
+
// console.error('Error deleting temp file:', err)
|
|
45
|
+
// } else {
|
|
46
|
+
// // console.log('Temp file deleted:', filePath);
|
|
47
|
+
// /*fs.rename(tempFilePath, filePath, (err) => {
|
|
48
|
+
// if(!err) {
|
|
49
|
+
// console.log(newName + ' 已重命名!')
|
|
50
|
+
// }
|
|
51
|
+
// })*/
|
|
52
|
+
// }
|
|
53
|
+
// })
|
|
54
54
|
})
|
|
55
55
|
})
|
|
56
56
|
}
|