【问题标题】:How to print out to a text file folder names within folder names (AppleScript)如何打印到文件夹名称中的文本文件文件夹名称(AppleScript)
【发布时间】:2017-10-28 00:45:25
【问题描述】:

我有一个部分有效的脚本。我需要打印出一个有效的文件夹名称列表。但是我需要进入每个文件夹的特定路径,然后打印出这些特定的文件夹名称。每当我尝试这样做时,我的文本文件都会显示为空白。我已将文本文件分开以尝试查找问题,无论我尝试什么,我都会得到相同的结果。第一个文本文件有效,但第二个文本文件始终为空白。理想情况下,我希望第二个文本文件使用脚本中指定的格式。任何指导将不胜感激。

tell application "Finder"
with timeout of 3600 seconds
    set src to (path to me) as string

    set multiPath to (src & "Contents:Resources:Fixed multiSteps")

    set zipFiles to {".zip"}


    set allPlugins to get name of every folder in folder ("" & multiPath & "") whose name extension is not in zipFiles
    set outputFile to ((path to desktop as text) & "pluginNames.txt")
    set typeFile to ((path to desktop as text) & "types.txt")

    set fileReference to open for access file outputFile with write permission

    set filetypeReference to open for access file typeFile with write permission

    try
        repeat with a in allPlugins

            write a & return to fileReference

            set innerPath to (a & "Double Click to Install.app:Contents:Resources")

            set innerFolders to get name of every folder in folder ("" & innerPath & "")

            repeat with b in innerFolders

                write a & " - " & b & return to filetypeReference

            end repeat

        end repeat

    end try

end timeout

end tell

【问题讨论】:

    标签: macos loops directory applescript macos-high-sierra


    【解决方案1】:

    好的,所以我想通了。

    tell application "Finder"
    with timeout of 3600 seconds
        set src to (path to me) as string
    
        set multiPath to (src & "Contents:Resources:Fixed multiSteps:")
    
        set zipFiles to {".zip"}
    
    
        set allPlugins to get name of every folder in folder ("" & multiPath & "") whose name extension is not in zipFiles
    
        set ListFile to ((path to desktop as text) & "List.txt")
    
        set filetypeReferenceList to open for access file ListFile with write permission
    
        try
            repeat with a in allPlugins
    
                set innerPath to (multiPath & a & ":Double Click to Install.app:Contents:Resources")
    
                set typesForList to get name of every folder in folder ("" & innerPath & "")
    
                write a & " - " & typesForList & return to filetypeReferenceList
    
            end repeat
    
        end try
    
    end timeout
    
    end tell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-06
      • 2017-04-22
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 1970-01-01
      • 2013-12-17
      • 1970-01-01
      相关资源
      最近更新 更多