Computing.Net > Forums > Programming > Using batch script print filenames in folder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Using batch script print filenames in folder

Reply to Message Icon

Name: sweetsruthi
Date: May 26, 2009 at 01:58:47 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: May 26, 2009 at 02:26:36 Pacific
Reply:

tree/f


0

Response Number 2
Name: Mechanix2Go
Date: May 26, 2009 at 02:50:17 Pacific
Reply:

@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


0

Response Number 3
Name: sweetsruthi
Date: May 27, 2009 at 00:29:07 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Using batch script print filenames in folder

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html

Printing RTF in Batch uses Defaults www.computing.net/answers/programming/printing-rtf-in-batch-uses-defaults/17104.html

Rename multiple iles in folder using Batch www.computing.net/answers/programming/rename-multiple-iles-in-folder-using-batch/19638.html