Applescript: Create folders/subfolders and move multiple files

后端 未结 2 1497
情书的邮戳
情书的邮戳 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 04:54

    Assuming your files are in the same folder, before

    this AppleScript:

    set pathToFolderOfTTUFiles to (path to the desktop as text) & "TTU:"
    tell application "Finder"
        set theFiles to every item of folder pathToFolderOfTTUFiles whose name extension is not "csv" and kind is not "Folder"
        repeat with theFile in theFiles
            set lengthOfExtension to (length of (theFile's name extension as text)) + 1
            set fileNameWithoutExtension to text 1 through -(lengthOfExtension + 1) of (theFile's name as text)
            set theFolder to make new folder at folder pathToFolderOfTTUFiles with properties {name:fileNameWithoutExtension}
    
            set theContentFolder to make new folder at theFolder with properties {name:"content"}
            make new folder at theContentFolder with properties {name:"archive"}
            set theContentDisplayFolder to make new folder at theContentFolder with properties {name:"display"}
            set theMetadataFolder to make new folder at theFolder with properties {name:"metadata"}
            make new folder at theMetadataFolder with properties {name:"archive"}
            set theMetadataDisplayFolder to make new folder at theMetadataFolder with properties {name:"display"}
    
            move theFile to theContentDisplayFolder
            set pathToCSV to pathToFolderOfTTUFiles & fileNameWithoutExtension & ".csv"
            if exists pathToCSV then move pathToCSV to theMetadataDisplayFolder
        end repeat
    end tell
    

    creates this: after

提交回复
热议问题