~pcwiz Posted May 15, 2008 Share Posted May 15, 2008 Hi, I am using AppleScript with POSIX paths and I am having trouble here. So say if I did this: set theFile to choose file with prompt "Choose a file" without invisibles The variable "theFile" would be something like this when I choose the file: HD:Kexts:mykext.kext So then I use POSIX to change the colons into slashes: set theFilePOSIX to POSIX path of theFile And the value of theFilePOSIX would be like: HD/Kexts/mykext.kext/ The problem is that POSIX puts a slash at the end of mykext.kext, so it gets messed up, any way to remove this slash? Link to comment Share on other sites More sharing options...
Airr Posted May 16, 2008 Share Posted May 16, 2008 Here's one way: set theFile to POSIX path of (choose file with prompt "Choose a file" without invisibles) set theLength to (length of theFile) - 1 set theFile to characters 1 thru theLength of theFile as string AIR. Link to comment Share on other sites More sharing options...
~pcwiz Posted May 16, 2008 Author Share Posted May 16, 2008 Thanks, but the problem with that method and the other one I tried is, strangely POSIX puts an extra slash on some kexts, but not for others, so sometimes it works for some kexts and for others it doesn't. I found the perfect solution though. tell application "System Events" to set newVariable to POSIX path of oldVariable Works fantastic. Link to comment Share on other sites More sharing options...
Airr Posted May 17, 2008 Share Posted May 17, 2008 tell application "System Events" to set newVariable to POSIX path of oldVariable Nice one! Thanks for the tip! AIR. Link to comment Share on other sites More sharing options...
Recommended Posts