Adjust Numbers in an expression by a set amount
-
It walks down from a given directory and loads the file with the txt extension and changes its contents if it matches something.
-
@Ekopalypse Would this work if the extension is VTT? It’s set to open as a text document but I don’t think that counts
-
@Leon-Bob-Noël said in Adjust Numbers in an expression by a set amount:
Would this work if the extension is VTT?
Not as it is. But, really, is it that hard to see it?
I mean, the relevant line in the code reads almost like English:if _file.endswith('.txt'):
Exercise left to the reader to figure out what to change it to. :-)
-
@Alan-Kilborn oh yeah, cool. So do I not run this whithin Notepad ++ then?
-
I’ve tried running it in Notepad ++ python scripts but no matter how I do it it does not work. With a file open in the directory it does nothing, with the directory open as workspace it does nothing, I didn’t try it with those setting with TXT files, assuming that changing it to “if _file.endswith(‘.vtt’)::” didn’t work because Notepad++ wasn’t recognizing them because it doesn’t recognize the extension by default & doesn’t have the language in it’s database
-
@Leon-Bob-Noël
It must run from within Npp but there is no need to load the file,
this is done by the script.
You just have to adjust the file ending and the root path.os.walk(r'PATH_WITHOUT_TRAILING_BAKSLASH'):
example
os.walk(r'C:\Documents\whatever\directory\it\is'):
-
@Ekopalypse Ah, thanks. Will is do recursive directories or just the root specified?
-
@Leon-Bob-Noël - it walks the tree recursively.
-
You could just experiment with it to find out these answers, instead of asking and then waiting to have a response.
-
@Alan-Kilborn if I was receiving answers while I was able to actually do it sure, but then if not I’d have to then ask if there was a way to do it. That seems much less efficient. I know when I’m helping someone I’d much rather have them ask questions right away. The longer they wait the less likely I’ll be looking at the forum to know they need a response. Maybe that’s just me, but having a question & waiting to ask it because it might not be necessary is just rude to the person giving help, while asking questions that are unnecessary right away is only really harmful to the ego of the asker, I’d rather look like I don’t know something I actually don’t know, than go to do something & have to come back & ask for more information because I was afraid of looking like an idiot, & thereby actually being an idiot