• 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: Is this possible in apple script? sed -e 's;\(.*/\).*;\1; | sed 's//share/HDA_DATA//Volumes/g'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this possible in apple script? sed -e 's;\(.*/\).*;\1; | sed 's//share/HDA_DATA//Volumes/g'


  • Subject: Re: Is this possible in apple script? sed -e 's;\(.*/\).*;\1; | sed 's//share/HDA_DATA//Volumes/g'
  • From: Thomas Fischer <email@hidden>
  • Date: Thu, 19 Dec 2013 17:52:40 +0100

Hello Vincent,

I'm afraid that your script in general will not do what you want it to do, one of the reason being a confusion between words and text items.

E.g, try
/share/HDA DATA/Travaux/PAO/PAO ENCOURS/Travaux/127266/Jpg/Jpg/Logo.jpg
This will give an error with

set all to count word of PathToItem
set essai to all - 1
set Dest to text items 1 thru all of PathToItem
…

since there are more words than 1 + (the number of text items).
In general, note that … thru -1 will give you all respective elements without the need to count them first.

set AppleScript's text item delimiters to "/"
set PathToItem to the clipboard as string
set Dest to "/Volumes/" & (text items 4 thru -2 of PathToItem & "" as string)
tell application "System Events" to open Dest

will probably yield what you want (I don't fully understand your replacement at the front).
Note that in the given case the first text item is empty, thus you have to start with text item 4, and
that the '& ""' adds an empty item at the end of the previous list to create the slash at the end.

Best
Thomas


Am 18.12.2013 um 21:03 schrieb Vincent:

/share/HDA_DATA/Travaux/PAO/PAO_ENCOURS/Travaux/127266/Jpg/Jpg/Logo.jpg



set AppleScript's text item delimiters to "/"
set PathToItem to the clipboard as string
set all to count word of PathToItem
set essai to all - 1
set Dest to text items 1 thru all of PathToItem
set the clipboard to result as string
set NextStep to the clipboard as string
set AppleScript's text item delimiters to "/"
set all2 to count word of NextStep
set almostThere to words 3 thru all2 of NextStep
set hereItIs to "/Volumes/" & almostThere
do shell script "open " & hereItIs & ""

 _______________________________________________
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: Is this possible in apple script? sed -e 's;\(.*/\).*;\1; | sed 's//share/HDA_DATA//Volumes/g' (From: Vincent <email@hidden>)

  • Prev by Date: Re: Access for Applescripts
  • Next by Date: Mail returns empty mailboxes in Mavericks
  • Previous by thread: Re: Is this possible in apple script? sed -e 's;\(.*/\).*;\1; | sed 's//share/HDA_DATA//Volumes/g'
  • Next by thread: SmartSet
  • Index(es):
    • Date
    • Thread