• 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: changing part of a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing part of a string


  • Subject: Re: changing part of a string
  • From: Luther Fuller <email@hidden>
  • Date: Mon, 28 Jan 2008 11:53:13 -0600

On Jan 28, 2008, at 10:31 AM, Ed Stockly wrote:
Huh. For some reason i had it in my head that AS strings were immutable.

I think Mark is right. This does not work on my mac:

set fullPath to "G5:bigfolder:2 color:myfolder:image1.eps"
set AppleScript's text item delimiters to {":"}
set text item 3 of fullPath to "CMYK images"

This does:

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set fullPath to every text item of "G5:bigfolder:2 color:myfolder:image1.eps"
set item 3 of fullPath to "CMYK Images"
set fullPath to fullPath as string
set AppleScript's text item delimiters to oldDelims

So, I checked the code I wrote just days ago. I was under the impression that I had written
set text item n of ... to ...
but I had not. And it does not work.
You DO have to convert the path name to a list; modify the list; then convert back to a full path.


And ... when creating the new full path, you have to qualify each item before adding it to the path name, otherwise, it's just a string that can't be used as an alias. In the example above, the new path is "G5:bigfolder:CMYK images:myfolder:image1.eps", but the folders "CMYK images" and "myfolder" will have to be created if they do not exist. You'll need to move or copy the file "image1.eps".

_______________________________________________
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
  • Follow-Ups:
    • Re: changing part of a string
      • From: Skeeve <email@hidden>
References: 
 >Re: changing part of a string (From: Ed Stockly <email@hidden>)

  • Prev by Date: Re: Getting array of Item names and Positions
  • Next by Date: Re: Getting array of Item names and Positions
  • Previous by thread: Re: changing part of a string
  • Next by thread: Re: changing part of a string
  • Index(es):
    • Date
    • Thread