Using batch script print filenames in folder

May 26, 2009 at 01:58:47
Specs: Windows XP
Hi,

From a folder i should print all the filenames with its directory name only once. how I can it using batch script.


say these are file names:

D:\Ant\latest\Updated2\html.txt
D:\Ant\latest\Updated2\java2.html
D:\Ant\latest\Updated2\pla.html
D:\Ant\latest\Updated3\README
D:\Ant\latest\Updated3\fetch.xml
D:\Ant\latest\Updated3\inifile.upd

Output should be:
Updated2\
html.txt
java2.html
pla.html

Updated3\
README
fetch.xml
inifile.upd


See More: Using batch script print filenames in folder

Report •


#1
May 26, 2009 at 02:26:36
tree/f

Report •

#2
May 26, 2009 at 02:50:17
@echo off & setLocal EnableDelayedExpansion

pushd D:\Ant\latest\

for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
pushd %%a
echo %%a
dir/b
popd
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#3
May 27, 2009 at 00:29:07
Thanks a lot for your solution. I has solved other problem.

but sorry i couldnot give the requriment clearly..

Acutally the requirment is:

With ANT script i have got all the filepaths modified after a specific date and stored it in a text file.

from this text file we should get only directory name once. and file name separately using batch script.

EX: new.txt contains:

D:\Ant\latest\Updated2\html.txt
D:\Ant\latest\Updated2\subup2\java2.html
D:\Ant\latest\Updated2\pla.html
D:\Ant\latest\Updated3\README
D:\Ant\latest\Updated3\fetch.xml
D:\Ant\latest\Updated3\inifile.upd

Output should be:
Updated2\
html.txt
updated2\subup2\
java2.html
pla.html

Updated3\
README
fetch.xml
inifile.upd


I have tried to do in this way:

take a empty text file. compare it with our directory name. If it doesnot match echo the output. and store this name into the text file again.

repeat this till the end.

But is there any good way to do this?

thank you.


Report •

Related Solutions


Ask Question