I have a folder folder1
contain 3 files file1
, file2
and file3
, etc.
I need command line to do the following task.
Store the name of the files in a variable because I want to write a dynamic batch.
batch-filecommand-line-interfacescriptingwindowswindows-command-prompt
I have a folder folder1
contain 3 files file1
, file2
and file3
, etc.
I need command line to do the following task.
Store the name of the files in a variable because I want to write a dynamic batch.
Best Answer
in a batch file will echo the filename of each file in the folder. To do the same thing at the command line, use only one percent sign for the variable. You can replace
echo
with some other command.If you quote the
%%f
, theecho
will output the quotes around the filename, but if you want to pass the filename to other commands the quotes may be necessary if there are special characters, such as spaces, in the filenames. For example, to output the contents of all the files:Without the quotes, if there was a file named "Has Space",
type
would try to output the contents of two files, "Has" and "Space". With the quotes, it will work as intended.