• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ongoing Senior moments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ongoing Senior moments


  • Subject: Re: ongoing Senior moments
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 01 Dec 2014 13:06:52 -0600

On Dec 01, 2014, at 05:53, Shane Stanley <email@hidden> wrote:
No; I was using a path to a folder that didn't exist. But I still don't fancy relying on it longer-term. Especially when there's a simple alternative:
______________________________________________________________________

Hey Folks,

This works fine on Mavericks (10.9.5):

-----------------------------------------------------------------------------
set theFolder to "~/Pictures/APOD ƒ/"
tell application "System Events"
  set pathPosix to POSIX path of item theFolder
  set pathHFS to path of item theFolder
end tell
-----------------------------------------------------------------------------

The trick is that the file/folder MUST ALREADY EXIST, which is NOT how the shell operates and is therefore unintuitive (not a big deal if you know).

-----------------------------------------------------------------------------
set shCMD to text 2 thru -1 of "
D=~/'Pictures/AM I NUTS?/'
if [ -e \"$D\" ]; then
  echo \"The disk item exists!\";
else
  echo \"The disk item does NOT exist!\";
fi
"
do shell script shCMD
-----------------------------------------------------------------------------

I stopped using the do shell script echo <string> method a long time ago, because it was much faster to do this:

-----------------------------------------------------------------------------
set path1 to "~"
set path2 to "~/"
set path3 to "~/Pictures/APOD ƒ/"
set path1Expanded to expandTildePath(path1)
set path2Expanded to expandTildePath(path2)
set path3Expanded to expandTildePath(path3)

on expandTildePath(_path)
  if _path is "~" or _path is "~/" then
    set _path to POSIX path of (path to home folder as text)
  else if _path starts with "~/" then
    set _path to (POSIX path of (path to home folder as text)) & text 3 thru -1 of _path
  else
    error "Bad path string!"
  end if
end expandTildePath
-----------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: ongoing Senior moments (From: Yvan KOENIG <email@hidden>)
 >Re: ongoing Senior moments (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: ongoing Senior moments
  • Next by Date: Re: Stack Overflow
  • Previous by thread: Re: ongoing Senior moments
  • Next by thread: Re: Stack Overflow
  • Index(es):
    • Date
    • Thread