我有一个有趣的问题,我希望可以通过shell命令轻松解决。我有一个目录树,其中的目录名是有意义的,每个目录内有几个文件,包括一个.mp3文件。重命名文件以匹配目录名称
我想批量重命名所有的mp3文件以匹配目录的名称。
例如高级别的目录看起来是这样的:
Seans-iMac% ls
2006.James Lovelock: Gaia’s Revenge
2006.Religion and stem cell research
2006.Stephen Schneider
2006.Tony Judt: Post-war Europe since 1945
2006.Water management
2007.'Here, Bullet'
2007.Alan Bennett
每个子目录的内容是相似的,如:
Seans-iMac% cd "2006.Religion and stem cell research"
Seans-iMac% ls
details.txt lnl_20060605.mp3 synopsis.txt
我想将它改成这样:
Seans-iMac% ls
details.txt 2006.Religion and stem cell research.mp3 synopsis.txt
我试过为循环但似乎无法获得参数正确。为了使它更复杂,目录名称有空格,并且有些单引号。
请更新您的代码到目前为止的问题 – 2013-03-11 13:50:12