如果不用 Ruby,我真不知道该怎么办
@@rules = [{ # 文件名转换规则 :from => /^(?\S+?) (?[^+])+(?[^+])+(?[^+])+((?[^+])+)?(?[^+]*)+(?[^+]+)$/, :to => '2013 年度\k<quarter>-\k<subject>-\k<district>-\k<rank>\k<promotion>-\k<title>-\k<author>-20130620', }, { :from => /^(?<rank>.+?) (?<quarter>.+?)((?<district>.+?))(?<author>.+?)( |—)(?<title>.+)$/, :to => '2013 年度\k<quarter>-\k<rank>-\k<district>--\k<title>-\k<author>', }, { :from => /^(?<rank>.+?)( |--)(?<author>.+?)(-|--)(?<title>[^-]+)$/, :to => '2013 年度---\k<rank>-\k<title>-\k<author>-2013-06-20', }, { :from => /^(?<rank>.+?)(\s+|--)(?<title>[^ -—]+?)(-+|—| )(?<author>[^ -—]+?)((-+|—| )(?<pubdate>\d+))?$/, :to => '2013 年度---\k<rank>-\k<title>-\k<author>-\k<pubdate>', }, { :from => /^(?<rank>[^ -]+?)( |--)(?<title>.+?)/, :to => '2013 年度---\k<rank>-\k<title>--2013-06-20', }]
文件名转换成功率达到了 99.69%(319/320)。