bash - 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.
解决方案
正如赛勒斯所建议的那样,解决方案是使用完整路径
推荐阅读
- python - 循环中的堆积条形图不添加条形的不同组件
- asp.net - Razor 页面:从何处获取正确的脚本引用语法
- android - 在多个字段上使用 Room 的 TypeConverters
- f# - 如何做一个简单的 elmish 路由器?
- c++ - C++获取重载成员函数指针的常用方法
- android - 保存对 Application 实例的引用会导致内存泄漏吗?
- r - 在不复制的情况下交换两个 SEXP
- django - 允许一个对象一次选择 ManyToMany 中的选项
- ruby - Ruby 和 ActiveRecord 初始化
- swift - 使用 UIGraphicsImageRenderer 图像检索像素数据无法正常工作