three little questions

how to get the complete path of :

set dpf to "~/Desktop/"

how to forbit name changes for a certain folder ?

its wise to use a repeat handler if the resulting can by only 1 item ?

POSIX path of (path to desktop)

Change the access privileges

No

Hi Stefan,

first answer:
hmm. I know how to get the long version for the Desktop. But, my question arises using the “~” tilde sign. Seems not possible to get the long version of the desktop (or any other) using posix paths.

second answer:
About to forbit name changes:
its fearly simple to change permissions, but i want to prohibit names changes only, which the user shouldn’t change, afflicting the correct function of an applescript routine. Because if you change permissions, you change the overall access to the specific folder.

kind regards
jo

You can use:

POSIX path of (path to home folder)

You can’t expand ~ directly in AS because that’s a shell function, and AS is not the shell.

You can’t do in AS what can’t be done any other way. AppleScript is really just an interface, not a magic tool.


set thePath to "~/Desktop" --for now lets say we don't know what kind of path it is

--with the folowing command we know for sure it's the absolute path
set thePath to do shell script "cd " & thePath & "; pwd"

Even if the code above works for simple folders as desktop I don’t recommend it. The problem is that quoted form on ~/Desktop won’t work. To quote the path yourself you should separate the first two characters from the rest of the path. Then characters 3 thru the last characters of the path can be quoted. This is because the ‘~/’ will only be replaced with the full path to the current user’s home folder when substitution is turned on (between the quotes substitution is turned off). The correct way to quote a path that starts with a tilde should be

set thePath to do shell script "cd ~/'Desktop/' ; pwd"

So to make it all work it should be

set thePath to "~/Desktop" --for now lets say we don't know what kind of path it is

if thePath begins with "~/" then set thePath to do shell script "cd ~/" & quoted form of text 3 thru -1 of thePath & " ; pwd"

I would go for a simpler solution like this:


set thePath to "~/Desktop" --for now lets say we don't know what kind of path it is

if thePath begins with "~/" then set thePath to POSIX path of (path to home folder) & text 3 thru -1 of thePath

This is the most efficient way and also the path doesn’t need to exist yet while with the cd and pwd example(s) the path must exist otherwise the root folder is returned “/”. Also the cd en pwd examples will only work with folders while the last example will also work with files as well.

Shan,
thanks for your reply. Some questions of me can sound strange not why i want to irritate somebody, but simple because i’m a self taught- coder. Have patience.

DJ Bazzie Wazzie
Yeee! thats a bottle of rum !
i did some experiments using variable properties, for this matter i posted my initial question