Rich

Rich / Active QSpace Pro

Last active 2 hours ago

Like 0

Get the currently-selected files in the active pane of QSpace Pro.

Rich revised this gist 2 hours ago · a9a1600

1 file changed, 35 insertions

active-qspace (file created)
@@ -0,0 +1,35 @@
1 + #!/usr/bin/osascript
2 + on convertListToString(theList, theDelimiter)
3 + set AppleScript's text item delimiters to theDelimiter
4 + set theString to theList as string
5 + set AppleScript's text item delimiters to ""
6 + return theString
7 + end convertListToString
8 +
9 + on isDirectory(someItem)
10 + set filePosixPath to quoted form of (POSIX path of someItem)
11 + set fileType to (do shell script "file -b " & filePosixPath)
12 + if fileType ends with "directory" then return true
13 + return false
14 + end isDirectory
15 +
16 + on run argv
17 + set output to {}
18 + tell application "QSpace Pro"
19 + set selectedItems to selected item of window 1
20 + repeat with i from 1 to count of selectedItems
21 + set filePath to urlstr of item i of selectedItems
22 + set fileString to characters 8 thru -1 of filePath as string
23 + set end of output to (do shell script "sed 's/%20/ /g' <<< " & quoted form of fileString)
24 + end repeat
25 + end tell
26 + repeat with i from 1 to count of output
27 + set theItem to item i of output
28 + if isDirectory(theItem) then
29 + set item i of output to quoted form of (theItem & "/")
30 + else
31 + set item i of output to quoted form of theItem
32 + end if
33 + end repeat
34 + return convertListToString(output, "\n")
35 + end run