Batch command to create empty txt files with the file names in a folder -
I have a folder of files, for example: 001zzzqqq. * 002bbbcc * 003nnnff. * ...
and want to create an empty text file named after each of those files, for example: 001zzzqqq.txt 002bbbccc.txt 003nnnfff.txt ...
Any quick way to knock it into the batch file? It seems that my mind has become empty on this.
Thanks
Files in folder:
For% (*) in% x ...
Create empty files:
type NUL & gt; % ~ Nx.txt
% ~ nx
evaluates the filename without the extension of the loop variable % x
. Then, combined:
For type (*) in the name of NUL & gt; You can also use copy NUL% ~ nx.txt
% ~ Nx.txt
but it will copy 1 file
And if the text file already exists, delete the errors; This is a more silent version (or use copy / y NUL% ~ nx.txt & gt; NUL 2 & gt; & amp; 1
.)
A batch file You need to double in %
but you will not need a batch file for this one-liner (except that it is part of a larger program):
Type (*) for x% NUL & gt; %% ~ nx.txt
Comments
Post a Comment