1
votes

I have routines that I'd like to make universal: instead of the selected folders, I'd like to stick to the user current user ("~/") when describing folder paths..

So my question is, if I select a folder with "Get Specified Finder Items" in automator, that outputs a -non applescript- list like this: ("path/to/my/folder"), how can I replicate it with applescript. Note the round brackets instead of the braces!

First I simply wanted to use this:

on run
  return {"~/path/to/my/folder/under/current/user"}
end run

And then I'd add the "Get Folder Contents" block..

Can anyone tell me why this wouldn't work? Thanks in advance!

2
of course, there would be more folders in the list.. thats why I need a list in the first place.ppseprus

2 Answers

2
votes

Well I might as well post what I was typing up for you anyway :-)

set folderTest1 to "test1"
set folderTest2 to "test2"


set homePath to POSIX path of (path to home folder as text) as text
set attachmentsFolder to (homePath & folderTest1 & "/" & folderTest2) as text

--OR


set homePath to POSIX path of (path to home folder as text) as text
set attachmentsFolder to (homePath & "test1/test2") as text

POSIX PATH changes the HFS+ path to a unix type path

path to home folder get to the users home folder

path to documents get the path to the users documents folder

POSIX file changes the unix type path to a HFS+ path

set homePath to POSIX path of (path to home folder as text) as text


set theHFSPath to (POSIX file homePath)
tell application "Finder"
    --The finder looks for the folders in the alais path of theHFSPath
    set theFolders to folders of (theHFSPath as alias) as alias list

    --> returns is a list of folders in the form of alais paths

end tell
0
votes

I solved it with the following code:

on run
return { POSIX path of ((path to home folder as text)) & "/path to my folder" as text, .. }
end run