在unix中,从一个路径读取.txt文件中的文件名,然后在另一个路径中重命名该文件

在unix中,从一个路径读取.txt文件中的文件名,然后在另一个路径中重命名该文件,unix,batch-rename,Unix,Batch Rename,我已经尝试了下面的代码,但是执行起来太长了。 有人帮我吗 #!/usr/bin/env bash echo -n "Enter Source_Path:" read src_path echo -n "Enter TXTFile_Name:" read f_name echo -n "Enter Desti_path:" read path cd $src_path while read -r line; do mv $path/$line $path/$line._$date echo "

我已经尝试了下面的代码,但是执行起来太长了。 有人帮我吗

#!/usr/bin/env bash
echo -n "Enter Source_Path:"
read src_path
echo -n "Enter TXTFile_Name:"
read f_name
echo -n "Enter Desti_path:"
read path
cd $src_path
while read -r line; do
  mv $path/$line $path/$line._$date
echo "Files are renamed."

源路径包含文本文件,在Desti_path中从中拾取并重命名文件名

您缺少
while
循环的
结束

如果您使用的是
bash
解释器,那么
while
循环应该适应以下样式

#!/usr/bin/env bash
...
while read -r line
do
    ...
    your_code_here
    ...
done