【发布时间】:2020-11-13 08:22:45
【问题描述】:
我有很多要重命名的 PDF。新名称应该是此 PDF 的文本项。我不想将其创建为文件夹操作以将 PDF 放入并重命名它们。到目前为止,我已经使用 Automator 和 AppleScript:
PDF 的整个文本被提取到桌面“PDF2TXT.rtf”(= 变量 theFileContents)上的新(临时)文件中,使用 Automator 操作从 PDF 中提取文本。
以下是将新名称与该文本分开的代码:
on run {theFileContents}
set od to AppleScript's text item delimiters
set theFileContentsText to read theFileContents as text
set myProjectNo to ""
set theDelimiter to "Projectno. "
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
set theArray to last text item of theFileContentsText
set theDelimiter to " "
set AppleScript's text item delimiters to theDelimiter
set myProjectNo to first text item of theArray
return myProjectNo
set AppleScript's text item delimiters to oldDelimiters
end run
我现在需要的是把输入的 PDF 重命名为“myProjectNo”。
很高兴提出任何建议。提前致谢。
q3player
【问题讨论】:
标签: pdf applescript file-rename