我有几个以十六进制格式命名的文件.我想大量地将它们重命名为它们的十进制类似功能,将它们从

  1. 0x000f750d.wav
  2. 0x000f750e.wav
  3. 0x000f750f.wav

  1. 1013005.wav
  2. 1013006.wav
  3. 1013007.wav

I've tried the following command in order 至 fetch the files' names in decimal and rename them, but I'm unsure how 至 go about it. (Note: before this command, I removed the .wav extensions from the files with the intent of readding them later 至 make it easier on myself.)

for f in *; do
    mv -- "$(($f))" $f;
done

这就是结果:

mv: cannot stat '1013005': No such file or direc至ry
mv: cannot stat '1013006': No such file or direc至ry
mv: cannot stat '1013007': No such file or direc至ry
mv: cannot stat '0': No such file or direc至ry

推荐答案

你基本上做到了,但论点的顺序错了.这应该会起作用,并删除$((...))的扩展名,然后将其添加回来:

for f in *; do mv -- "$f" "$((${f/%.wav})).wav"; done

Linux相关问答推荐

在Bluez/Linux中,周期性与连续蓝牙设备发现的已知缺陷是什么?

在CefExecuteProcess;之前创建新线程会导致CEF应用程序崩溃并显示SIGTRAP

是否可以在Bash正则表达式中排除?

如何在带模式的文件频繁更改的管道中使用grep-f带模式的文件?

从一个文件中读取文件名并将文件名和内容存储到另一个带有|的文件中作为分隔符

Boost更新失败,现在不确定我有哪个版本

使用 sed 命令仅打印正则表达式匹配

linux shell获取多文件交集

从 curl 命令输出中获取值

当未在日志(log)中输入确切的时间戳时如何过滤日期范围内的值

每次来宾重新启动后 Vagrant 执行脚本或命令(vagrant up)

具体来说,fork() 如何处理 Linux 中 malloc() 动态分配的内存?

为什么在 Linux 中使用 select

size_t 和 off_t 的用法有什么区别?

如何通过 ssh 判断 ubuntu 服务器上是否存在 php 和 apache

如何下载较旧的 google play 服务?

docker compose:加载共享库时出错:libz.so.1:无法从共享对象映射段:不允许操作

Anaconda:禁用提示更改

在文件夹中的 gzip 文件中查找字符串

svn over HTTP 代理