Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PF.WrapSelectionWithFolder.applescript
- --
- -- Created by Peter Geil on 05.12.09.
- -- Copyright 2009 Peter Geil. All rights reserved.
- registerWithGrowl()
- tell application "Path Finder"
- set pfSelectionList to selection
- if length of pfSelectionList = 0 then
- return
- end if
- set cwd to (POSIX path of container of first item of pfSelectionList)
- set folderName to text returned of ¬
- (display dialog cwd ¬
- default answer ¬
- "Untitled folder" with title "Enter folder name")
- set joinedPath to (cwd & "/" & folderName)
- if not (exists joinedPath) then
- if (do shell script "mkdir '" & joinedPath & "'") is not equal to "" then
- displayGrowlMessage("Error occured", "Folder couldn't be created") of me
- return
- end if
- end if
- set listOfWrappedFiles to ""
- try
- repeat with i in pfSelectionList
- set listOfWrappedFiles to (listOfWrappedFiles & name of i & return)
- if (do shell script "mv '" & (POSIX path of i) & "' '" & (joinedPath & "/" & name of i) & "'") is not equal to "" then
- error "File '" & (POSIX path of i) & "' couldn't be moved"
- end if
- end repeat
- on error
- displayGrowlMessage("Error occured", "Files couldn't be move to target folder") of me
- return
- end try
- displayGrowlMessage("Wrapped " & length of pfSelectionList & " file(s)", listOfWrappedFiles) of me
- end tell
- on displayGrowlMessage(headline, msg)
- tell application "GrowlHelperApp"
- notify with name ¬
- "DefaultMsg" title ¬
- (headline) description ¬
- (msg) application name "Path Finder"
- end tell
- end displayGrowlMessage
- on registerWithGrowl()
- tell application "GrowlHelperApp"
- set the allNotificationsList to ¬
- {"DefaultMsg"}
- set the enabledNotificationsList to ¬
- {"DefaultMsg"}
- register as application ¬
- "Path Finder" all notifications allNotificationsList ¬
- default notifications enabledNotificationsList ¬
- icon of application "Path Finder"
- end tell
- end registerWithGrowl
Add Comment
Please, Sign In to add comment