Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on hazelProcessFile(theFile)
- set theProjectFiles to {}
- set thisFile to {}
- set theBigScript to ""
- tell application "Finder"
- set file_list to entire contents of theFile
- end tell
- repeat with anItem in file_list
- set thisFile to getPath(anItem)
- if (item 3 of thisFile) contains "logic" then
- set end of theProjectFiles to (anItem as alias)
- else if (item 3 of thisFile contains "wav") or (item 3 of thisFile contains "aif") or (item 3 of thisFile contains "aiff") then
- set theBigScript to (theBigScript & "/usr/local/bin/flac -s -f -V --lax --best --delete-input-file '" & (POSIX path of (anItem as alias)) & "' -o '" & (POSIX path of (item 1 of thisFile)) & (item 2 of thisFile) & "." & (item 3 of thisFile) & ".flac' ; ")
- end if
- end repeat
- repeat with theProject in theProjectFiles
- set thisFile to getPath(theProject)
- tell application "Finder" to set theContainer to container of theProject
- do shell script ("mv '" & (POSIX path of (theProject as alias)) & "' '" & (POSIX path of (theContainer as alias)) & (item 2 of thisFile) & "." & (item 3 of thisFile) & ".compressed'")
- end repeat
- do shell script theBigScript
- end hazelProcessFile
- on getPath(input)
- -- this subroutine accepts an alias as input and returns an array with three items, a file path (as string), a filename stripped of extensions, and a file extension
- set filePath to (input as string)
- try
- set oldDelims to AppleScript's text item delimiters -- save their current state
- set AppleScript's text item delimiters to {":"} -- declare new delimiters
- set theFileName to (last text item of filePath)
- set AppleScript's text item delimiters to oldDelims -- restore them
- on error
- set AppleScript's text item delimiters to oldDelims -- restore them in case something went wrong
- beep
- end try
- set strippedPath to (characters 1 thru ((offset of theFileName in filePath) - 1) of filePath) as string
- tell application "System Events" to tell disk item (filePath as text) to set {fileString, fileExtension} to {name, name extension}
- if fileExtension is not "" then set fileString to text 1 thru -((count fileExtension) + 2) of fileString -- the name part
- return {strippedPath, fileString, fileExtension}
- end getPath
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement