I have a folder consisting of approximately 500 txt files. The names of these txt files were recorded as 001.txt, 002.txt….478.txt.
The contents of these files are as follows
cd C:UsersAnarShycafeintest
unimportant words here >> 1mayis.txt
unimportant words here >> 1mayis.txt
unimportant words here >> 1mayis.txt
What I want to do is to replace the 1mayis.txt text in these files with the name of that file.
For example, I want to automatically convert the content of the 001.txt file to the following.
Before
cd C:UsersAnarShycafeintest
unimportant words here >> 1mayis.txt
unimportant words here >> 1mayis.txt
unimportant words here >> 1mayis.txt
Later
cd C:UsersAnarShycafeintest
unimportant words here >> 001.txt
unimportant words here >> 001.txt
unimportant words here >> 001.txt
In summary, I want to replace the word 1mayis.txt in 500 txt files with the original name of the file it is in.
I tried to change the files one by one with ctrl+H, but it took an extremely long time.
Cansu Bal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.