AppleScript循环询问(3)问题,选择多个finder文件,将结果合并到一个文本文件中

时间:2016-01-25 07:08:18

标签: macos applescript automator

我正在寻找一些帮助获取苹果脚本设置。我一直试图通过网络上的不同示例复制和过去无济于事。我正在为家庭成员设置日记/日记,需要有一个包含以下信息的文本文件。

AppleScript将显示一个对话框,询问三件事:
    事件的名称     活动日期     事件描述

每个都将作为单独的变量存储。

然后脚本将要求从Finder中选择一些文件,没有嵌套,只有15-30个文件的选择都包含在同一个文件夹中。

最后将创建一个新的TextEdit文档 文档的开头将(3)变量与一些默认文本混合在一起。 文件的中间部分将根据从查找程序中选择的文件数填充重复循环。他们的文件路径将与其他默认文本混合在一起。 最后一部分只是默认文本,不需要变量。

我确信我的描述比脚本可能更复杂。有人能为我提供这个脚本吗?非常感谢。

这是一个粗略的想法,最终的东西会是什么样子。粗体区域是变量。

  

当天的活动潜水。
  你去潜水的日期是 2016年1月1日   这是对您的活动的描述。这一天非常美丽,水很完美。你能看到各种各样的鱼!

     

这些是此事件中文件的位置   第一个文件是 /events/scuba/scuba1.txt
  这些是此事件的文件位置   第一个文件是 /events/scuba/scuba2.txt
  这些是此事件的文件位置   第一个文件是 /events/scuba/scuba3.txt

     

这是您潜水活动的摘要。这些记忆将持续一生!

我很感激这方面的帮助。如果有问题的家庭成员能够提供感谢,请知道他们也会这样做。

2 个答案:

答案 0 :(得分:0)

我可以使用Evernote建议替代解决方案吗?

您可以使用表格创建“模板”注释,以填写活动,日期和说明。只要您想要新的日记帐分录,只需选择模板,然后转到备注>复制到笔记本。

然后您可以附加和/或导入文件的文本。

这还允许您添加图像和其他附件,并且搜索更容易。当然,这很容易分享。

如果您想了解更多详情,请与我们联系。

示例屏幕截图: enter image description here

答案 1 :(得分:0)

你可以这样做:

set evName to text returned of (display dialog "The name of an event" default answer "")
set evdate to text returned of (display dialog "The date of the event" default answer "")
set evDesc to text returned of (display dialog "A description for the event" default answer "")

set theText to "The activity of the day was " & evName & return & "The date you went " & evName & " was " & evdate & return & evDesc & return & return
set x to choose file with multiple selections allowed

set def1 to "These are the locations of the files from this event."
set def2 to "The first file is "
repeat with i in x
    set theText to theText & def1 & return & def2 & (POSIX path of i) & return
end repeat

set theText to theText & return & "This was a summary of your " & evName & " activity. These memories will last a lifetime!"
tell application "TextEdit"
    make new document with properties {text:theText}
    activate
end tell