我想将丑陋的文件名(作为我的糟糕编程的副产品)更改为“ Booklet xxx.pdf kopie.pdf”到“ xxx.pdf”。Automator将其更改为>“ xxx.pdf”(文件名前的空格非常烦人...
这就是我能想到的...
tell application "Finder"
set allFiles to selection
search of (name of every item of allFiles) for "Booklet "
try
if file exists then delete "Booklet " of name
end try
search of (name of every item of allFiles) for ".pdf kopie"
try
if file exists then delete ".pdf kopie" of name
end try
end tell
非常感谢!
您可以通过设置name
属性来重命名文件:
activate application "SystemUIServer" -- http://www.openradar.me/9406282
tell application "Finder"
activate
repeat with f in (get selection)
if name of f ends with "kopie.pdf" then
set name of f to text 9 thru -11 of (get name of f)
end if
end repeat
end tell
或在shell中运行以下内容:
cd directory; for f in *kopie.pdf; do f2=${f% *}; mv "$f" "${f2##* }"; done
${f% *}
移除的最短 *
距离的端部图案f
和${f2##* }
去除最长*
从开始模式f2
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句