1. Getting file names
- Posted by Matt <matt1 at MEDIACOM.IT> Nov 02, 1997
- 540 views
- Last edited Nov 03, 1997
Hi again to everybody. Two questions in a day... I hope you won't get mad at me... This time I need to get all the full names (names and extensions) of the files contained in a given path but without the path. For example: C:\temp\temp2\a.txt C:\temp\temp2\b.txt C:\temp\temp2\c.txt C:\temp\temp2\temp3\a.txt I have to obtain a ASCII *text* file : (I have to read this file with an editor) a.txt b.txt c.txt a.txt *or also*: a.txt b.txt c.txt a.txt (don't care for duplicates) And would it possible to read long name files with Euphoria? I'm sorry for these questions that may appear stupid but I'm new to Euphoria and to this mailing list. Thanks for your help and have a nice day. Matt
2. Getting file names
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Nov 04, 1997
- 533 views
- Last edited Nov 05, 1997
2 days ago, Matt wrote: >Hi again to everybody. >Two questions in a day... I hope you won't get mad at me... >This time I need to get all the full names (names and >extensions) of the files contained in a given path but without >the path. >For example: >C:\temp\temp2\a.txt C:\temp\temp2\b.txt C:\temp\temp2\c.txt >C:\temp\temp2\temp3\a.txt >I have to obtain a ASCII *text* file : (I have to read this >file with an editor) >a.txt b.txt c.txt a.txt *or also*: >a.txt b.txt c.txt a.txt >(don't care for duplicates) > And would it possible to read long name files with Euphoria? > I'm sorry for these questions that may appear stupid but I'm >new to Euphoria and to this mailing list. >Thanks for your help and have a nice day. >Matt Ciao Matteo, Since I have not seen an answer to this question, I'll give you my suggestion. dir() is a function in the include file files.e. In library.doc you can read this: Command: dir = Syntax: = include file.e x =3D dir(st) = Description: = Return directory information for the file or directory named by st. If there is no file or directory with this name then -1 is returned. = This information is similar to what you would get from the DOS DIR command. A sequence is returned where each element is a = sequence that describes one file or subdirectory. = = If st names a directory you may have entries for "." and "..", just as with the DOS DIR command. If st names a file then x will have just one entry, i.e. length(x) will be 1. = = Each entry contains the name, attributes and file size as well = as the year, month, day, hour, minute and second of the last = modification. You can refer to the elements of an entry with = the following constants defined in file.e: = global constant = D_NAME =3D 1, D_ATTRIBUTES =3D 2, D_SIZE =3D 3, = D_YEAR =3D 4, D_MONTH =3D 5, D_DAY =3D 6, = D_HOUR =3D 7, D_MINUTE =3D 8, D_SECOND =3D 9 = The attributes element is a string sequence containing = characters chosen from: = d - directory r - read only file h - hidden file s - system file v - volume-id entry a - archive file = A normal file without special attributes would just have an empty string, "", in this field. = = Comments: = The top level directory, e.g. c:\ does not have "." or ".." entries. = = This function is often used just to test if a file or = directory exists. = Under Windows 95, st can have a long file or directory name = anywhere in the path. = The file name returned in D_NAME will be a standard DOS 8.3 name, even on Windows 95 or Windows NT. A new long-filename element may be added in a future release of Euphoria. = Example: = = d =3D dir(current_dir()) = = -- d might have: { {".", "d", 0 1994, 1, 18, 9, 30, 02}, {"..", "d", 0 1994, 1, 18, 9, 20, 14}, {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40}, {"sub", "d" , 0, 1993, 9, 20, 8, 50, 12} } = = d[3][D_NAME] would be "fred" = Example Programs: = bin\search.ex, install.ex See Also: = wildcard_file, current_dir, open = Hope this helps, Sincerely, Ad Rienks email Ad_Rienks at compuserve.com writing at 0:58 , = on Wednesday 5 November 1997