Automated Search & Replace help please
Tobias Ray last edited by PeterJones
I have a file where I want to do an extensive search and replace utilizing a subtitutions.txt file containing all the search terms and their replacements. The search terms often have spaces in their names like;
User Logged Off.ico
The replacement may also have multiple spaces like;
User Logged Off 32.ico
I have installed Python Script and have been trying to get a couple of scripts I found to work, but they use single word search and replace terms.
This is the main script I have tried;
with open('C:/Temp/Substitutions.txt') as f: for l in f: s = l.split() editor.replace(s, s)
If I change the split seperator to (‘#’) it seems to work except I get and extra LF character after every replace which destroys the code.
Notepad+ is such a brilliant product and I had not realised that you could use Python with it - it’s great that it has pushed me to try and get to grips with Python, even though it is proving frustrating at the monment.
Any help much appreciated. Thanks for reading.
moderator added text block to make question clearer
Alan Kilborn last edited by
@tobias-ray said in Automated Search & Replace help please:
I get and extra LF character after every replace which destroys the code
s = l.rstrip('\n\r').split('#')
Tobias Ray last edited by
@alan-kilborn said in Automated Search & Replace help please:
s = l.rstrip(‘\n\r’).split(‘#’)
Hi alan-kilborn, thanks so much for the help. In my simple test, that does solve the problem, appreciated.
I will now give it a try for real and no doubt realise a few further issues.