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
|