閱讀816 返回首頁    go iPhone_iPad_Mac_apple


how to fix delimiter in this applescript?

My goal is to take a directory with files with multiple names that follows the same general rule:

{_jackm-12334-02-01.jpg , _namid-0231-103-0123.jpg , _neverbe-03342-232.jpg ......"

these files moved into subfolders of their own with only the "word" such as "_jackm" as the name of the folder and only files with _jackm inside it ... etc.

here is the script, but having a problem with delimiter,

error "Finder got an error: Can’t get text item delimiters." number -1728 from text item delimiters


--script begins

 

on run

    set theFolder to ""

    set fileList to {}

    set theTarget to ""

    set theText to ""

    set TID to {}

    set textItems to {}

   

    tell application "Finder"

        set theFolder to (choose folder with prompt "Choose containing folder:" without invisibles and multiple selections allowed)

        set fileList to every file of theFolder

        repeat with i in fileList

            name of i as text

            set theText to "_londondire_123455-901-34"

            set {TID, text item delimiters} to {text item delimiters, "-"}

            set textItems to text items of theText

            set text item delimiters to TID

            set theResult to item 1 of textItems -- "londondire"

            try

                set theTarget to ((theFolder as text) & theText) as alias

                move i to theTarget

            on error

                make new folder at theFolder with properties {name:theText}

                move i to result

            end try

        end repeat

    end tell

end run

 

--script ends



The term is "Applescript's text item delimiters" not just "text item delimiters"



最後更新:2017-08-18 09:28:46

  上一篇:go MB Pro(2017)no longer see Bonjour printer
  下一篇:go How to find "repair permissions"?