1000 files, increment each first line number by 1
-
I have 1000 txt files (000-999) and I would like to increment the first (and only) line by one. I already have the first line of text on each file, Is there a way to do a search and replace across multiple files so that each file’s first line increases by one.
All files have the first line: first_line_of_text_
and would like to make the first line of each file:
(the first file) first_line_of_text_000
(second file) first_line_of_text_001
etcIs there a way to do a search & replace so that each file’s first line is increased by 1?
Many thanks
-
@dajaridi
Natively by npp, jein(yes/no).
Of course you can come up with a regex that appends 000 in the first file, 001 in the second … , but that would be an insanely long one, I guess.
I assume that learning some basics in a scripting/programming language wouldn’t take much longer and would give you a lot more options afterwards. -
@dajaridi I might have something that you can use, but not with notepad ++, But with a bat file, if your interested
-
@Javier-Rivas Yes please, that would be great! Thank you. I had done it once before and I was sure it was with notepad++ but maybe it was a bat.
-
@Ekopalypse I’m new here, can we share batch file here, if it helps to rename file names? I believe that is what he is asking to rename a .txt filename by adding 000 in front on his filename and counting. I would of never thought that notepad++ can rename a txt filename
-
@dajaridi to make sure I understand this, you have 100 .txt files and you would like to rename all the txt files by adding a counter in front of the name right, 001 filename.txt, 002 filename.txt and so on
-
@Javier-Rivas No, not the text file name itself, but the first line of text in each file.
-
You can add the source of the batch file by adding
~~~
.
before and after the source, but you can’t attach files to the post.
For example@echo off set X=%%1 ...
But I think OP is asking about manipulating the file contents
instead of the individual file names. -
@dajaridi the context of a file, like you are editing a txt files and inside you have
Example
I am
John
SmithAnd in front of that you want a counter
001 I am
002 John
003 SmithLike it’s counting rows, if please give an example
-
@Ekopalypse Yes, adding a number starting with 000, last being 999 to the first line of text. Thanks for contributing
-
@dajaridi ok, ok I think I got only the first line, only the first line of context on each txt file
-
All files have the first line: first_line_of_text_
and would like to make the first line of each file:
the_first_file.txt
first_line_of_text_000the_second_file.txt
first_line_of_text_001 -
@Javier-Rivas Yes!
-
@dajaridi my files do that but for file names, I’ll do my best to help you
-
@Javier-Rivas If you have an idea that might help, I would be thankful>
For renaming a number of files I use a very useful utility called BulkRename Utility. -
@Javier-Rivas I have been able to achieve my objext using notepad++ although it is quite inelegant.
I have a folder with 1000 text files, which I duplicated. I then renamed them with a suffix 000.txt -> 999.txt
Each file has a unique first line, with a name and number, and all I did was do a search and replace to add in an extra zero and change the _001 to _0001
It will give me a unique first line, but will be a little more messy when combine with the other folder – but will work for what I am after.
Thanks for your help!! Most appreciates.
Daja
PS I know I’ve done it before, and it’s driving me nuts that I don’t remember how or where I found it…