Jump to content

Print all the filenames -- using batch script

- - - - -

  • Please log in to reply
3 replies to this topic

#1
html82

html82

    Newbie

  • Members
  • Pip
  • 1 posts
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:\files\year\2010\html.txt
D:\files\year\2010\java2.html
D:\files\year\2010\pla.html
D:\files\year\2011\README
D:\files\year\2011\fetch.xml
D:\files\year\2011\inifile.upd

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

2011\
README
fetch.xml
inifile.upd

#2
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
Is there any specific reason you are doing this with a batch script? You can use a .bat file to call a vbscript or a .NET console program that will do this for you and write the information to the console.
-CDG10620
Software Developer

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
I believe the DOS command 'tree' will do this for you, although I am not sure if it exists anymore.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
This is about the closest I can get you to it without using tree.

DIR D:\Files\year /S /W

If you want them sorted alphabetically within their respective folders:
DIR D:\Files\year /S /W /ON

Edited by dargueta, 25 February 2011 - 05:15 PM.
Fixed syntax error

sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users