• 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: Converting Unix path to AppleScript path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting Unix path to AppleScript path


  • Subject: Re: Converting Unix path to AppleScript path
  • From: deivy petrescu <email@hidden>
  • Date: Mon, 27 Mar 2006 20:28:04 -0500


On Mar 27, 2006, at 18:31, Stockly, Ed wrote:

Hi,

I'm looking for a simpler and more reliable way to convert a UNIX style path (read from an XML file) to an appleScript style path (file "volume:directory:directory:file.ext" or alias "volume:directory:directory:file.ext")
<snip>
ES


(Here's what I'm doing now.

FixPhotoPath("file:///Volumes/Mag_Production/Color Lab Images/ 03:26/Issue #9 prepressed/tm.0326.chinaRS.tiff")

<snip>

Ed, as Gnarlie said, the "03:26" is generally not good. However, your script converts it to "03/26" so, I assume this conversion is fine.


Here is a script that will do what you want:

<scrip>

set astid to AppleScript's text item delimiters
set fil to "file:///Volumes/Mag_Production/Color Lab Images/03:26/ Issue #9 prepressed/tm.0326.chinaRS.tiff"
-- no line wrapping
tid("///Volumes/")
set fil to POSIX path of (item 2 of text items of fil)
set fil to text 2 thru -1 of (replace(replace(fil, " ", space), "% 23", "#"))
tid(astid)
fil




on tid(a)
	set AppleScript's text item delimiters to a
end tid


on replace(txt, from_string, to_string) tid(from_string) set txt to text items of txt tid(to_string) return txt as Unicode text end replace

</script>

Note that the second "set fil" can have more recursions if you need to change more characters. Also, the first "set fil" can be avoided altogether if you are not afraid of ugly expressions.


Deivy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Converting Unix path to AppleScript path
      • From: Gnarlodious <email@hidden>
References: 
 >Converting Unix path to AppleScript path (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: split up text for Powerpoint
  • Next by Date: Re: Converting Unix path to AppleScript path
  • Previous by thread: Re: Converting Unix path to AppleScript path
  • Next by thread: Re: Converting Unix path to AppleScript path
  • Index(es):
    • Date
    • Thread