我已经尝试这样做了几个月,但是我无法使其正常工作。我正在尝试bash。所有文件都在linux机器上,所以bash
我猜呢?
我想做什么:对于目录中的所有文件,请使用以下条件重命名它们:
[312646416198]
(2018)
,请保留该年份(并非都包含该年份)(1)
的方括号,请删除方括号和数字根据文件名的第一部分创建一个文件夹(例如,导致第一个连字符“-”的所有内容),然后将该文件移动到创建的文件夹中。
因此,例如,以下名称在经过一些处理后应该(理想情况下)看起来像这样。某些东西会放错地方,例如title出现在author之前,因此新文件夹将以title命名,而不是author命名,但是我可以接受,只有一小部分这样命名。
所以这:
The Brotherhood of the Rose - David Morrell.epub
Abbi Glines - Bad for You (2014) [9781481420761] (1).epub
Kristin Hannah - The Great Alone (2018) [9781250165619].epub
Stephanie Dray, Laura Kamoie - America's First Daughter - A Novel (2016) [9780062347268] (1).epub
Terence Hanbury White - The Once and Future King (1987) [9780441627400] (1).epub
变成这个:
The Brotherhood of the Rose
The Brotherhood of the Rose - David Morrell.epub
Abbi Glines
Abbi Glines - Bad for You (2014).epub
Kristin Hannah
Kristin Hannah - The Great Alone (2018).epub
Stephanie Dray, Laura Kamoie
Stephanie Dray, Laura Kamoie - America's First Daughter - A Novel (2016).epub
Terence Hanbury White
Terence Hanbury White - The Once and Future King (1987).epub
这可能起作用:
$ cat epub-cleanup.sh
#! /bin/bash
for i in *.epub; do
mv -iv "$i" "$(echo "$i" | sed -r 's/\[[0-9]+\]//;s/\([0-9]\)//;s/[ ]*.epub/.epub/')"
done
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句