Notepad++ python , remove the path from the text file
-
script
Filename = notepad.getCurrentFilename() editor.addText( Filename )Result - “d:\folder\file.txt”
What I want - “file.txt”
-
Well, you have to use Python code to do that.
The “editor” functions give you all of the information; if you want a subset, you have to do it yourself.You might try:
import os Filename2 = Filename.rsplit(os.sep, 1)[-1] -
Perfect, it works. This is to replace strings in my sourcepawn template.
import time import os Filename = notepad.getCurrentFilename() FilenameEnd = Filename.rsplit(os.sep, 1)[-1] timeStr = time.strftime( '%I:%M %p' + ' - ' + '%d-%m-%Y' ) editor.rereplace(r"TM_FILEDATE", ( timeStr )) editor.rereplace(r"TM_FILENAME", ( FilenameEnd ))Thanks!!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login