Thanks for the help! I modified the script. It is now:
- Code: Select all
tell application "Finder"
set tid to AppleScript's text item delimiters
set myHazelTokenDelimiters to "|"
set theListOfCustomTokens to name of theFile
set AppleScript's text item delimiters to {myHazelTokenDelimiters}
-- Now, the tokens are available in theListOfCustomTokens as items 1,2,3 etc...
-- The following is an example
set Name1 to (text item 1 of theListOfCustomTokens)
set Name2 to (text item 2 of theListOfCustomTokens)
set Name3 to (text item 3 of theListOfCustomTokens)
end tell
tell application "Finder"
set posix_parent_dir to the quoted form of the POSIX path of (container of (item theFile) as text)
end tell
set AppleScript's text item delimiters to space
set escapedSpace to ""
if ((the number of text items of posix_parent_dir) > 1) then
repeat with counter from 1 to ((the number of text items of posix_parent_dir) - 1)
set escapedSpace to escapedSpace & (text item counter of posix_parent_dir & (ASCII character 92)) & space
end repeat
set escapedSpace to escapedSpace & (the last text item of posix_parent_dir)
set posix_parent_dir to escapedSpace as text
end if
tell application "System Events"
activate
display dialog posix_parent_dir
end tell
try
set showFolders to ((do shell script "find " & posix_parent_dir & " -maxdepth 1 -mindepth 1 -type d -name \"*\" -print") as text)
tell application "System Events"
activate
display dialog showFolders
end tell
on error
tell application "System Events"
activate
display dialog "Find Failed"
end tell
end try
and it still doesn't work. In a word, AAAAAARRRRRRRGGGGGHHHHH!!!!!!!!!!!! Also, I think you meant to put a space after the find and before the " in the second code section. You put it in the first section, but not the second. (See, I am starting to pick up something here, but I still hate Shell Scripts)
My concern is that when I escape the space in the path name I am screwing something up. Thanks again!
Bryan
p.s. As I was writing this, it suddenly dawned on me. I am using this on a certain folder only. It will ALWAYS be at the path '/Volumes/Snow Leprd/Data/Clients/' so I changed the find to this:
- Code: Select all
tell application "Finder"
set tid to AppleScript's text item delimiters
set myHazelTokenDelimiters to "|"
set theListOfCustomTokens to name of theFile
set AppleScript's text item delimiters to {myHazelTokenDelimiters}
-- Now, the tokens are available in theListOfCustomTokens as items 1,2,3 etc...
-- The following is an example
set Name1 to (text item 1 of theListOfCustomTokens)
set Name2 to (text item 2 of theListOfCustomTokens)
set Name3 to (text item 3 of theListOfCustomTokens)
end tell
try
set showFolders to ((do shell script "find /Volumes/Snow\\ Leprd/Data/Clients/ -maxdepth 1 -mindepth 1 -type d -name \"*\" -print") as text)
tell application "System Events"
activate
display dialog showFolders
end tell
on error
tell application "System Events"
activate
display dialog "Find Failed"
end tell
end try
with the path hardwired in it works. It isn't so portable, but I am not planning to move it to any other folder for the moment. Thanks for helping me through this, and if someone comes up with the answer, I would love to hear it.
Bryan