I have a file.txt where are located the names for file, for example file1 file2 file3

I want to create empty txt files with this names which are located in file.txt so i if i have 10 columns of text i need create 10 empty txt file.

How i can make it?

I know that like this command you can create empty file


I don't believe this possible in batch considering its major limitations, but I'll give it a shot.

This may help: https://stackoverflow.com/questions/19540089/how-to-get-the-list-of-filenames-in-a-directory-and-store-that-in-a-variable-usi

Here is some code that puts each filename in a directory into an array, you could then add some code that uses those filenames as a base and adds up to those:

@echo off
setlocal disableDelayedExpansion
:: Load the file path "array"
for /f "tokens=1* delims=:" %%A in ('dir /s /b^|findstr /n "^"') do (
  set "file.%%A=%%B"
  set "file.count=%%A"

:: Access the values
setlocal enableDelayedExpansion
for /l %%N in (1 1 %file.count%) do echo !file.%%N!

Personally, I would make a file simply called file.txt and use that as my base filename to create new files with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.