Applescript: Create folders/subfolders and move multiple files

后端 未结 2 1514
情书的邮戳
情书的邮戳 2021-01-17 04:47

I have an Applescript question that is much more complex than I can construct. I have been searching for the past couple of days, and I cannot find any script like this, nor

2条回答
  •  半阙折子戏
    2021-01-17 05:07

    Try:

    set myFolder to "Mac OS X:Users:stark:Main Folder"
    tell application "Finder" to set myFiles to folder myFolder's files as alias list
    repeat with aFile in myFiles
        tell application "System Events" to set {fileName, fileExt} to {name, name extension} of aFile
        set baseName to text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
        do shell script "mkdir -p " & (quoted form of (POSIX path of myFolder)) & "/" & baseName & "/{\"content\",\"metadata\"}/{\"display\",\"archive\"}"
        tell application "System Events"
            if fileExt is "pdf" then move aFile to (myFolder & ":" & baseName & ":content:display" as text)
            if fileExt is "csv" then move aFile to (myFolder & ":" & baseName & ":metadata:display" as text)
        end tell
    end repeat
    

提交回复
热议问题