【问题标题】:Can you write folder actions with javascript (jxa)?你能用 javascript (jxa) 编写文件夹操作吗?
【发布时间】:2016-12-15 03:38:57
【问题描述】:

我正在寻找 AppleScript 的直接翻译

on adding folder items to this_folder

但我似乎无法在任何地方找到它,无论是术语的使用还是关键字 this_folder 本身。

【问题讨论】:

    标签: automation applescript javascript-automation


    【解决方案1】:

    使用 Automator,我可以构建一个文件夹操作工作流来显示仅使用 JavaScript 移动到文件夹的文件的路径:

    function run(input, parameters) {
       var app = Application.currentApplication();
       app.includeStandardAdditions = true;
       var text = "FileName = " + input[0];
       var options = { };
       app.displayAlert(text, options);
    
       return input;
    }
    

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      文件夹操作在标准添加中定义。此操作的完整语法是:

      on adding folder items to this_folder after receiving added_items
      

      您的 JXA 脚本应该看起来像这样

      app = Application.currentApplication()
      app.includeStandardAdditions = true
      
      function addingFolderItemsTo(this_folder, {afterReceiving:added_items})
      {
          app.beep(2)
         // your code here uses this_folder and/or added_items
      }
      

      参数:

      this_folder 是接收文件夹的别名。

      added_items 是已删除项目的别名列表。

      【讨论】:

      • 很遗憾没有:'(
      • 函数签名应该是addingFolderItemsTo(this_folder, added_items);但这仍然行不通。
      猜你喜欢
      • 1970-01-01
      • 2011-06-07
      • 1970-01-01
      • 2015-05-18
      • 2019-03-10
      • 2012-01-11
      • 1970-01-01
      • 2015-12-17
      • 2011-01-11
      相关资源
      最近更新 更多