Guest User

Untitled

a guest
May 16th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. -- PF.WrapSelectionWithFolder.applescript
  2. --
  3.  
  4. -- Created by Peter Geil on 05.12.09.
  5. -- Copyright 2009 Peter Geil. All rights reserved.
  6.  
  7.  
  8.  
  9. registerWithGrowl()
  10.  
  11. tell application "Path Finder"
  12.  
  13. set pfSelectionList to selection
  14.  
  15. if length of pfSelectionList = 0 then
  16. return
  17. end if
  18.  
  19. set cwd to (POSIX path of container of first item of pfSelectionList)
  20. set folderName to text returned of ¬
  21. (display dialog cwd ¬
  22. default answer ¬
  23. "Untitled folder" with title "Enter folder name")
  24. set joinedPath to (cwd & "/" & folderName)
  25.  
  26. if not (exists joinedPath) then
  27. if (do shell script "mkdir '" & joinedPath & "'") is not equal to "" then
  28. displayGrowlMessage("Error occured", "Folder couldn't be created") of me
  29. return
  30. end if
  31. end if
  32.  
  33. set listOfWrappedFiles to ""
  34.  
  35.  
  36. try
  37. repeat with i in pfSelectionList
  38. set listOfWrappedFiles to (listOfWrappedFiles & name of i & return)
  39. if (do shell script "mv '" & (POSIX path of i) & "' '" & (joinedPath & "/" & name of i) & "'") is not equal to "" then
  40. error "File '" & (POSIX path of i) & "' couldn't be moved"
  41. end if
  42. end repeat
  43. on error
  44. displayGrowlMessage("Error occured", "Files couldn't be move to target folder") of me
  45. return
  46. end try
  47.  
  48.  
  49. displayGrowlMessage("Wrapped " & length of pfSelectionList & " file(s)", listOfWrappedFiles) of me
  50. end tell
  51.  
  52. on displayGrowlMessage(headline, msg)
  53. tell application "GrowlHelperApp"
  54. notify with name ¬
  55. "DefaultMsg" title ¬
  56. (headline) description ¬
  57. (msg) application name "Path Finder"
  58. end tell
  59. end displayGrowlMessage
  60.  
  61. on registerWithGrowl()
  62. tell application "GrowlHelperApp"
  63. set the allNotificationsList to ¬
  64. {"DefaultMsg"}
  65.  
  66. set the enabledNotificationsList to ¬
  67. {"DefaultMsg"}
  68.  
  69. register as application ¬
  70. "Path Finder" all notifications allNotificationsList ¬
  71. default notifications enabledNotificationsList ¬
  72. icon of application "Path Finder"
  73. end tell
  74. end registerWithGrowl
Add Comment
Please, Sign In to add comment