PDA

View Full Version : A means to get txt file of all files within directory



MichelleX
July 28th, 2006, 06:59 AM
Some of you guys may already know about this, but I just found this out last night and thought it would be useful to share (especially in the dynamic image loading projects):

How to create a text file list of the contents of a folder: (Win)

Go to your DOS prompt and type:

- Type c: (or whatever the drive letter is that you're trying to get to) and hit Enter.
- Type in the "cd\" command with the full path to your folder you want the text file created from.
example: cd\Documents and Settings\MichelleX\Desktop\project\images
- Then type the "dir >" command, along with the name of the text file you want and hit Enter.
example: dir >myimages.txt

So now, if you go to your folder, you'll have a text file in there with a list of all things in that directory. With a little bit of cleaning up, you could just copy/paste those file names in your xml sheet or whatever you're using.

cheers,
~Michelle

icio
July 28th, 2006, 10:59 AM
Thanks for sharing :)

Devil_6
July 28th, 2006, 12:24 PM
first go to you directory and then type

dir *.jpg /b > pictures.txt

- it show just a listing of the .jpg files with '*.jpg'
- it strips the sh*t out of the listing with '/b'

? want to see the contents ?
type: 'type pictures.txt'

Good luch and see 'dir /?' for more easy commands

Chris

MichelleX
July 28th, 2006, 02:21 PM
Right on =)
Thanks Chris!

~

brianmanden
July 28th, 2006, 02:46 PM
With >> you can add to an existing text file.

Example:

dir /b /dir1/*.jpg >filelist.txt
dir /b /dir2/*.jpg >>filelist.txt

^ will give you a list of jpg´s from dir1 AND dir2.

Sifodyas
July 29th, 2006, 08:19 AM
If you directory structure something like set1, set2, set3, you could opt to use the following:

FOR /L %f in (1, 1, 10) do dir /b set%f/*.jpg >> filename.txt
The /L parameter will let you work with a sequence of numbers, where IN (start, step, end).

With the code example above, it would place all the file listings from set1 to set10 into one output file (using the >> example by brian).

eta: silly mistake in syntax (forgot to put filename at end!)

Xeef
July 29th, 2006, 03:16 PM
whit ">"

you can redirect ANY output of ANY dos comand to a file ;)

netstat -a >sime.txt
ipconfig >some.txt

...
..

Esherido
July 29th, 2006, 08:14 PM
Awesome work, that could come in really useful later on if I ever have to do anything like that.

EmeniusXp
July 30th, 2006, 12:45 AM
Really nice to remember this kind of things we used to use in the old DOS days.

quite a flashback :D

phorte
July 30th, 2006, 03:15 AM
Someone feeling really adventurous could put all this stuff into an application, for us DOS noobs. :)

signifer123
July 30th, 2006, 08:57 AM
Someone feeling really adventurous could put all this stuff into an application, for us DOS noobs. :)

http://www.sendspace.com/file/i9vv3u

a simple one...makes a batch file that dumps listing into dirList.txt

supports bare , subdirectory, sorting, filter and multiple directory(all are dumped into the same file).

It cleans out the dirList left over by the last time you ran the batch file so...to change that just edit the > on the first line to be a >>

Is that what you wanted, or you wanted a graphical application that just does the file listing? I figured a batch file would be more useful.








? want to see the contents ?
type: 'type pictures.txt'


My A+ professor told me i got that wrong becuase i said edit...edit is better! It has search and replace and everything you'd want a from a primitive version of notepad. And some features notepad doesn't have, like dual panes. And you can change text colors and all that jazz. See what all of you GUI people have been missing :P

do edit...it has a interface :)
alt is to access the menu

Xeef
July 30th, 2006, 06:55 PM
if i am not wrong is "type" in opossite to "Edit" a real DOS command

so it's aviable as fare you have a MS-DOS (or any other compatible dos)

for edit you need an extra file (edit.com) wich for example won't by there if you boot from a plain dos disk (don't tell me that is't there by winXP ... as then use notepad)

and "edit" use noobs

use "edlin" if you think you can take it :D

Seb Hughes
July 30th, 2006, 07:03 PM
When i want to create a file say.

Sebs Stuff.txt and it has a space it will only create sebs without an extension what is a space in msdos?

so i can create a file with a space in it?

signifer123
July 30th, 2006, 08:03 PM
yes put quotes around the filename "sebs stuff.txt"

Rats, Beaten again...at least there always vim for linux ..theres emacs ... :(
isn't there vim for dos too?

owww...edlin is horrible i feel it owuld be easier to write a C program to write the text file...then again how would i do that without a text editor.

Edit:
at least edit works in DOS 5 and higher, edlin is annoying, you have to dump the file then choose what line you want to edit...but i got it just use the insert command...alot easier...

though W lineNumberHere is good too.

Glad i never had to use DOS when it didn't have the windows shell on it :)