Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.updOutput should be:
Updated2\
html.txt
java2.html
pla.htmlUpdated3\
README
fetch.xml
inifile.upd

@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

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.updOutput should be:
Updated2\
html.txt
updated2\subup2\
java2.html
pla.htmlUpdated3\
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.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |