Thread: split in Python
View Single Post
  #1 (permalink)  
Old Jun 4th, 2006, 22:40
pmichael pmichael is offline
New Member
Join Date: Aug 2003
Location: USA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
split in Python

I can get the fullpath filename into a variable
CurDoc=App.ActiveDocument.Name

when I print I see "F:\dir1\dir2\dir3\dir5\filename.ext"

I need to get just 'filename.ext' into a variable. So I try:
NewFileName=CurDoc.split("\")[5]

or if it isn't zero-based I can put 6, but that's not the issue right now ...

I'm doing this within the Paint Shop Pro pspscripting environment which uses Python.

Every time I try to run this I get the error:

Executing RunScript
File "<string>", line 49
NewFileName=CurDoc.split("\")[5]
^
SyntaxError: invalid token

and that ^ is actually pointing at the period between CurDoc and split.

Any PSP scripters or Python users?

Thanks!
Reply With Quote