小编Pai*_*kes的帖子

(Bash) 重命名文件扩展名

我在尝试创建脚本以将目录中的所有文件重命名为.txtLinux 上时遇到问题。

这是我到目前为止所拥有的。

#!/bin/bash

location_number=$(find /hw1/textarchive | wc -l)
org_path=/hw1/textarchive/!(*txt)
count=0

#for count in $location_number
#do
    # rename $org_path .txt 
    #rename $org_path *.txt
    # mv $org_path  $org_path.txt
#done

for count in $location_path
do
    rename $org_path .pro .txt *.pro  <-----was trying to just rename .pro to .txt (no luck)
done

echo done
Run Code Online (Sandbox Code Playgroud)

我尝试使用mvandrename但没有任何结果。当mv $org_path $org_path.txt我运行时,我会收到类似于 的错误(this file) is not a directory。有了rename它,运行时不会出现任何错误,但它不会将任何文件重命名为.txt.

linux bash rename files

3
推荐指数
1
解决办法
4681
查看次数

标签 统计

bash ×1

files ×1

linux ×1

rename ×1