首页 > 解决方案 > How to iteratively rename files in Bash

问题描述

I am trying to iterate over files in a folder, renaming them as foldername1, foldername2, etc. However, I'm getting an error which says that the mv isn't being used correctly.

So far my code looks like this:

FILES='(Full Path)/Macbeth/audio/'
for file in "$FILES"*
do
    mv $file 'Macbeth'$i''
done

The final code should iterate through the files and rename them as, in this case Macbeth1.mp3, but I'm not sure how the Bash syntax works.

标签: bashterminal

解决方案


正如赛勒斯所建议的那样,解决方案是使用完整路径


推荐阅读