1. File Listing
- Posted by cklester <cklester at HOTPOP.COM> May 04, 2000
- 399 views
I need a program that will output a file list, including subfolders... kinda like this: Forms <dir> Texas <dir> doc1.doc doc2.doc New York <dir> doc3.doc doc4.doc California <dir> doc2.doc doc4.doc Anybody wanna help? Thanks! ck
2. Re: File Listing
- Posted by Alan Tu <alantu at STUDENTS.UIUC.EDU> May 04, 2000
- 391 views
Yes, go to a DOS prompt, and type dir/b/s This will give you a list of all files and sub dirs, just the names no dates, and to get it to a txt file dir/s/b > dir.txt to have the date info preserved, dir/s > dir.txt Alan ----- Original Message ----- From: "cklester" <cklester at HOTPOP.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Thursday, May 04, 2000 2:34 PM Subject: File Listing > I need a program that will output a file list, including subfolders... kinda > like this: > > > Forms <dir> > Texas <dir> > doc1.doc > doc2.doc > New York <dir> > doc3.doc > doc4.doc > California <dir> > doc2.doc > doc4.doc > > Anybody wanna help? > > Thanks! > ck >
3. Re: File Listing
- Posted by Robert Craig <rds at ATTCANADA.NET> May 04, 2000
- 398 views
- Last edited May 05, 2000
C.K. Lester writes: > I need a program that will output a file list, > including subfolders... > kinda like this: > Forms <dir> > Texas <dir> > doc1.doc > doc2.doc > New York <dir> > doc3.doc > doc4.doc > California <dir> > doc2.doc > doc4.doc That sounds like a job for walk_dir()... -- list.ex - display files in a directory and subdirectories -- usage: ex list directory -- e.g. ex list . -- ex list \windows include file.e sequence start_dir, list, cl cl = command_line() start_dir = cl[3] list = {} function save_name(sequence path_name, sequence entry) -- called by walk_dir() for each file and directory sequence file_name file_name = entry[D_NAME] if find('d', entry[D_ATTRIBUTES]) then file_name &= '\\' end if for i = 1 to length(path_name) do if path_name[i] = '\\' then file_name = " " & file_name end if end for -- we could simply print the name, but let's make a list list = append(list, file_name) return 0 -- keep going end function if walk_dir(start_dir, routine_id("save_name"), 1) != 0 then puts(2, "walk_dir failed!\n") end if -- display the results for i = 1 to length(list) do puts(1, list[i] & '\n') end for Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
4. Re: File Listing
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> May 05, 2000
- 395 views
- Last edited May 06, 2000
Hello CK Lester, > > I need a program that will output a file list, > > including subfolders... > > kinda like this: > > Forms <dir> > > Texas <dir> > > doc1.doc > > doc2.doc > > New York <dir> > > doc3.doc > > doc4.doc > > California <dir> > > doc2.doc > > doc4.doc I tried my hand at this but I see Robert has beaten me to the punch. However, I couldn't get Robs solution to run so I perservered with my own and now its finally finished. I thought of using walk_dir but decided to hard code everything to be as customizable as possible. This demo prints the Euphoria directory structure to a file called Test.txt. You could just as easliy use these routines to print to the screen or any file. Here is the source: include file.e type string (object s) -- an ASCII ignorent string type if not sequence (s) then return 0 end if for i = 1 to length (s) do if sequence (s[i]) then return 0 end if end for return 1 end type function get_file_list (sequence path) -- get the dir structure of a dir sequence ret object temp ret = {} temp = dir (path) if atom (temp) then puts (1, "Error: bad path.") abort (1) end if for i = 1 to length (temp) do if find ('d', temp [i] [D_ATTRIBUTES]) then -- it's a directory if not equal ( temp [i] [D_NAME] , "..") and not equal ( temp [i] [D_NAME] , ".") then ret = append (ret, {temp[i][D_NAME],get_file_list(path&'\\'&temp[i][D_NAME])} ) end if else ret &= {temp [i] [D_NAME]} end if end for return ret --{{path, ret}} end function constant tab = 4 -- how many spaces each indention is procedure print_list (integer fn, sequence data, integer level) for i = 1 to length (data) do puts (fn, repeat (' ', level * tab)) if string (data [i]) then puts (fn, data [i] & '\n') elsif sequence (data [i]) then -- its a directory puts (fn, "\n" & repeat (' ', level * tab)) puts (fn, data [i][1] & " <dir>\n") print_list (fn, data [i][2], level+1) end if end for end procedure procedure print_file_list (integer fn, sequence path) puts (fn, path & " <dir>\n\n") print_list (fn, get_file_list (path), 1) end procedure constant f = open ("test.txt", "w") print_file_list (f, "c:\\Euphoria") I hope this is useful, . __ _____ __ __ __ __ _____ . /\ \ /\ \|\ \ /\ \ /\ \ /\ \ /\ \ . / \_\ / \____\ \_\/ \_\/ \_\/ \_\/ \____\ . / / / / / ___/ | | / | / / / /\ / __ \ . / / / / / /_\ | | | / | / / / /\_\/ /_ \/ ./ / /\ / / ___/ | | |/ | / / / /\ \ \__ \ .\ / /__\\ / /__\ \ | /| |/ /\ / / \/\_\/ / . \/_____/ \/_____/ \|___/\|___/ \/_/ \_____/ keroltarr at hotmail.com http://geocities.com/keroltarr/ ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com