Linux系统批量重命名文件名

Linux系统批量重命名文件名

𝓓𝓸𝓷 Lv6

批量修改文件名,批量修改名称,批量修改文件名前缀

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
(1) Linux批量改文件名:
for txt in *.txt; do
mv "$txt" "new_${dir%*/}";
done

for txt in `ls Full-*`; do
mv "$txt" "new_${txt}";
done


(2) Linux批量改文件名前缀:

---去掉文件名new前缀
for txt in `ls *.txt`; do
mv "$txt" "${txt#new}"
done

for file in *.txt; do
mv "$file" "$(echo $file | sed 's/^old/new/')"
done

for file in Full-*; do
mv "$file" "$(echo $file | sed 's/^Full/log/')"
done

find . -type f -name "*.txt" -exec rename 's/^old/new/' {} +

find . -type f -name "*.txt" -exec rename 's/^Full/log/' {} +
  • Title: Linux系统批量重命名文件名
  • Author: 𝓓𝓸𝓷
  • Created at : 2025-05-09 11:17:30
  • Updated at : 2025-05-09 11:17:37
  • Link: https://www.zhangdong.me/linux-batch-rename-file-names.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
评论