# Linux 批量修改文件名（前缀或后缀）

有些文件的要求前缀或后缀要一样，或者批量的将文件重命名。

添加前缀：for i in \`ls\`; do mv -f $i \`echo "text\_"$i\`; done

替换后缀：rename 's/\\.txt/\\.csv/' \*

实例如下：

```
depuser@TSDEP61:/csdn$ ls
1.txt  2.txt  3.txt  4.txt  5.txt
depuser@TSDEP61:/csdn$ for i in `ls`; do mv -f $i `echo "text_"$i`; done
depuser@TSDEP61:/csdn$ ls
text_1.txt  text_2.txt  text_3.txt  text_4.txt  text_5.txt
depuser@TSDEP61:/csdn$ rename 's/\.txt/\.csv/' *
depuser@TSDEP61:/csdn$ ls
text_1.csv  text_2.csv  text_3.csv  text_4.csv  text_5.csv
```

[原文链接](https://blog.csdn.net/weixin_42003671/article/details/89920342)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.linh.eu.org/xi-tong-ruan-jian-cao-zuo/linux-pi-liang-xiu-gai-wen-jian-ming-qian-zhui-huo-hou-zhui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
