I have a text file with 30 names in it. I need to make 30 empty text files each called name from the list. Is there an easy way of doing this? Naming 30 text files one by one seems kind of frustrating. I use notepad++
1 Answer
Assuming you're on Windows, if the filenames are in filenames.txt
, one per line, do
for /f "delims=" %F in (filenames.txt) do copy nul "%F"
If you have multiple words per line, this will create files whose names contain spaces.
-
I have 1 name per line. I type this in cmd? And what will it give out?– BoshyAug 13, 2014 at 22:48
-
Ok I tried it and it gave me many files but not text files. Also one file was "blabla" type of file because name contained a dot "name.blabla".– BoshyAug 13, 2014 at 22:50
-
It should give you empty files (that's what
copy nul ...
does). If your filename list containsfoo.txt
andbar.txt
, then you should get (empty) text files. If your filename list containsred.jpg
andblue.jpg
, then you should get (empty/invalid) JPEG files. And if you have non-alphanumeric characters like^
in your filename list, then you will get files with non-alphanumeric characters in their names. Aug 13, 2014 at 22:56 -
-
Didn't I answer that when I said "if your filename list contains
foo.txt
andbar.txt
, then you should get (empty) text files"? But, if your filename list contains filenames without extensions, change the end of the command in my answer todo copy nul "%F".txt
. Aug 13, 2014 at 23:12