• 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
Routine for parsing path-filename....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Routine for parsing path-filename....


  • Subject: Routine for parsing path-filename....
  • From: Stefan Eriksson <email@hidden>
  • Date: Sat, 27 May 2006 11:18:34 +0200

Hello !

Trying to get a routine to parse a path like this, i have the path and i have the filename and i want the result to 

set thePath to "PB G4 Ster:Users:ster:Documents:Project:Aktuella projekt:Breweries:East Europe:Baltic:100-150 Zelta Gold.pdf"
set the_file to "100-150 Zelta Gold.pdf"
gives
set pathresult to "PB G4 Ster:Users:ster:Documents:Project:Aktuella projekt:Breweries:East Europe:Baltic:"

Following routine works just fine, returns "PB G4 Ster:Users:ster:Documents:Project:Aktuella projekt:Breweries:East Europe:Baltic:"

set tset thePath to "PB G4 Ster:Users:ster:Documents:Project:Aktuella projekt:Breweries:East Europe:Baltic:100-150 Zelta Gold.pdf"
set the_file to "100-150 Zelta Gold.pdf"

set replaceItWith to ""
set newText to switchText of thePath from the_file to replaceItWith

to switchText of theText from SearchString to ReplaceString
set oldDelims to AppleScript's AppleScript's text item delimiters
set AppleScript's AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's AppleScript's text item delimiters to oldDelims
return newText
end switchText

But when i try to get the code in a loop or as a routine i hit problems... anyone got an idea of how to be able to get the parsingcode to work as a routine ?

Got this far... wont compile stops on the "to switch text..."

set thePath to "PB G4 Ster:Users:ster:Documents:Project:Aktuella projekt:Breweries:East Europe:Baltic:100-150 Zelta Gold.pdf"
set the_file to "100-150 Zelta Gold.pdf"

parse(thePath, the_file)

on parse(thePath, the_file)
set replaceItWith to ""
set newText to switchText of thePath from the_file to replaceItWith

to switchText of theText from SearchString to ReplaceString
set oldDelims to AppleScript's AppleScript's text item delimiters
set AppleScript's AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's AppleScript's text item delimiters to oldDelims
return newText
end switchText
end parse

Any ideas, maybe there is an easier way to do the parsing thing !?

best regards, Stefan

 _______________________________________________
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: Routine for parsing path-filename....
      • From: Emmanuel <email@hidden>
    • Re: Routine for parsing path-filename....
      • From: dev_sleidy <email@hidden>
    • Re: Routine for parsing path-filename....
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: iTunes : "File permission error"
  • Next by Date: Re: iTunes : "File permission error"
  • Previous by thread: Re: iTunes : "File permission error"
  • Next by thread: Re: Routine for parsing path-filename....
  • Index(es):
    • Date
    • Thread