Hello,
I am trying to create a list with file\folder names fro the directory commandd and the file-info information for each member of the list.
I have the output in 2 lists and I am trying to use a map with a push to combine them. However the push returns just the item that was pushed.
If someone can help with an example of how create a list of files and there info and also how can values from one list be pushed into a list of lists.
Thanks,
I hope I was understandable.
Steven
creating a list from directory and file-info
-
cormullion
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
I'm not sure you need two lists - you can get file-info for every item in a list produced by directory by mapping a function over the list:
If you have two lists that match, you can combine them neatly:
Code: Select all
(set 'dirlist (directory "/"))
(map (fn (f) (println f "\t" (file-info f))) dirlist)
;->
..Developer (476 16893 0 0 80 1175695159 1175694126 1175694126)
etc (3162 41453 0 0 80 1127373182 1127373182 1137361024)
Library (1870 17405 0 0 80 1175791160 1174234983 1174234983)
mach (603684 41453 0 0 80 1174913732 1174913732 1174913732)
..
Code: Select all
(set 'dirlist (directory "/"))
(set 'infolist (map (fn (f) (file-info f)) dirlist))
(transpose (list dirlist infolist))
or
(map list dirlist infolist)
Last edited by cormullion on Thu Apr 05, 2007 6:23 pm, edited 1 time in total.
... and to combine two lists you would do the following:
Lutz
Code: Select all
> (set 'list-1 '(a b c d))
(a b c d)
> (set 'list-2 '(1 2 3 4))
(1 2 3 4)
> (map list list-1 list-2)
((a 1) (b 2) (c 3) (d 4))
>
Hi,
When I do
I get the following.
Steven
When I do
Code: Select all
(map list list-1 list-2)I get the following.
How can I make it that it each file name and it's info be in one list like the following.("Demo.lsp" (1408 33206 2 0 0 1177559281 1174002288 1174002288))
("Drag.lsp" (1152 33206 2 0 0 1177559281 1174002288 1174002288))
thanks(("Demo.lsp" 1408 33206 2 0 0 1177559281 1174002288 1174002288)
("Drag.lsp" 1152 33206 2 0 0 1177559281 1174002288 1174002288))
Steven
-
cormullion
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
I think you want to use "cons" rather than "list" here.
Code: Select all
(set 'file-name-list (directory "/"))
(set 'file-info-list (map file-info file-name-list))
(map cons file-name-list file-info-list)
( ("Applications" 3808 16893 0 0 80 1177793256 1177531823 1177531823)
("Applications (Mac OS 9)" 578 16895 0 501 80 1177793345 1175184313
1175184313)
...