Reading Input Text file using batch file, and creating files

August 6, 2012 at 22:52:29
Specs: Windows XP
I have directory and file list in a text file. Using batch file i need to read the text file content and have to create the listed directories and files(msword, excel)

See More: Reading Input Text file using batch file, and creating files

Report •

August 7, 2012 at 06:14:26
could anyone help to the above

Report •

August 7, 2012 at 09:58:03
can you provide a list that is within the text file, and then what you want done exactly?

:: mike

Report •

August 7, 2012 at 21:28:33
Thanks for your reply mike
My Text file contain the following data

My requirement is, i have to read the above text file and create those folders and files using batch file.

Currently iam giving the following command
FOR /F "delims=~" %%i in (mylist.txt) Do (
SET lineContent=%%i
md "%%i" )

As iam providing "md" its creating all the paths in text file as directories.But i need,if the path in the textfile is directory i have to create directory,else if it is file i have to create file.

Thanks in advance

Report •

Related Solutions

August 8, 2012 at 23:30:09
There is "technically" no way to know, from simple text file line, whether the objective is a file or a directory. That is not possible unless other data is given elsewhere.
IF you can allow assumptions, such as dot=file, no-dot=directory, then yes, you could do pattern-match. MS filenames may not have dots, and MS directorynames
might HAVE dots, so this assumption must be anticipated for possible errors.
@echo off & enabledelayedexpansion
for /f "tokens=1* delims=." %%a in (list.txt) do (
:here is where the ASSumption comes in.
if "%%b" equ "" (
md %%a
) else (

(not tested. any directorynames with "." will cause fail. any filenames with no
extension (ie: no ".") will also cause failure.

Report •

Ask Question