Domanda

I have a bunch of empty files (with different names). How can I add text to them e.g. not copy-paste the text to the 2000 files one by one.

Is this possible in NOTEPAD++?

Thanks in advance.

È stato utile?

Soluzione

assuming the text you want to add is simple enough and they are all txt files, navigate to the directory where they are and create a run.bat file with the following contents

for %%f in (*.txt) do (        
      echo your text here >>%%f
)

thanks should be given to https://stackoverflow.com/users/37923/mark and https://stackoverflow.com/users/2666/jim-buck

Naturally, I would recommend a test first before going through your thousand files.

Altri suggerimenti

If you want to write a string of characters to many files you can use echo A string of characters > *.txt . All the text file will now contain A string of characters. If the text content is in a file text then you can use type text > *.txt. Now all the *.txt file will have same content as content of file text. All these commands should be typed at command prompt. You must be knowing >,>>,<,<< are the redirection operators.

A pure Notepad++ solution would use the Find in files variation of search, which has a Replace in files facility. Set Find what to be \A\z meaning start of buffer immediately followed by end of buffer; make sure that Regular expressions are selected. Put the required text into the Replace with field. Use the Filters and Directory fields and the three tick boxes (below the close button) to select the files.

Caution All empty files that are found by the file search criteria will be changed.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top