【发布时间】:2017-07-28 00:01:13
【问题描述】:
我有一个格式为 pdf 的文件:
Author-YYYY-rest_of_text_seperated_by_underscores.pdf
John-2010-some_file.pdf
Smith-2009-some_other_file.pdf
我需要重命名文件,以便将年份放在第一位,例如
YYYY-Author-rest_of_text_seperated_by_underscores.pdf
2010-John-some_file.pdf
2009-Smith-some_other_file.pdf
这意味着将 'YYYY-' 元素移到开头。
我没有 unix 'Rename',必须依赖 sed、awk 等。我很乐意就地重命名。
我一直在尝试调整这个答案,但运气不佳。 Using sed to mass rename files
【问题讨论】:
-
请不要使用实际上不在问题本身中心的工具来标记问题。
awk和sed在答案中可能有用,但它们并不是您真正要问的。