creating custom text file from directory listing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gema Gema

    creating custom text file from directory listing

    I have a large collection of directories full of various files and am
    looking to create custom text files for the contents of each
    directory. Here is the situation:

    The directories are named with a name and number, i.e. Smith1234567.
    I am looking to create a text file named with the number portion of
    the directory name (1234567.txt). The contents of the text file would
    look similar to the following, where the "TIF" files at the end of
    each line are the contents of each directory:

    0001234567,Poli cy Archive,ARCHVE, \CUSTOMER\IMAGE S\T100204021514 14500001.TIF
    0001234567,Poli cy Archive,ARCHVE, \CUSTOMER\IMAGE S\T100204021514 14500002.TIF
    0001234567,Poli cy Archive,ARCHVE, \CUSTOMER\IMAGE S\T100204021514 14500003.TIF
    0001234567,Poli cy Archive,ARCHVE, \CUSTOMER\IMAGE S\T100204021514 14500004.TIF
    0001234567,Poli cy Archive,ARCHVE, \CUSTOMER\IMAGE S\T100204021514 14500005.TIF

    So basically, a text file containing 3 leading zeroes followed by the
    number portion of the directory name, the text "Policy
    Archive,ARCHVE, \CUSTOMER\IMAGE S\" followed by the filename; one line
    in the text file per file in the directory.

    Obviously, my question is if and how it can be done.

    Thanks in advance,
    Gema


  • R.Wieser

    #2
    Re: creating custom text file from directory listing

    Gema Gema <dcharat@hotmai l.com> schreef in berichtnieuws
    iqj4c.1464$GQ3. 826@newsread3.n ews.atl.earthli nk.net...

    Hello Gema,
    [color=blue]
    > I have a large collection of directories full of various files and am
    > looking to create custom text files for the contents of each
    > directory. Here is the situation:
    >
    > The directories are named with a name and number, i.e. Smith1234567.
    > I am looking to create a text file named with the number portion of
    > the directory name (1234567.txt).[/color]

    If the numeric portion of that name is fixed, the answer is to use a simple
    RIGHT$( {string},LEN( {string} )- {fixed number} ) .

    If not, two methods are available :
    A) move back from the end until you find a non-numeric char (use MID$( ) for
    this), move one stap back (to the last numeric char, and use MID$( ).
    B) Move forward untill you find a numeric char, and use MID$( ) . This may
    cause troubles if the "name" portion of the directory is something like
    "123Smith123456 7" or "smith123_12345 67"

    To append two strings together, use '&' : DirName$=right$ ( .... ) & ".txt"
    [color=blue]
    > The contents of the text file would
    > look similar to the following, where the "TIF" files at the end of
    > each line are the contents of each directory:[/color]

    [Snip]
    [color=blue]
    > So basically, a text file containing 3 leading zeroes followed by the
    > number portion of the directory name, the text "Policy
    > Archive,ARCHVE, \CUSTOMER\IMAGE S\" followed by the filename; one line
    > in the text file per file in the directory.[/color]

    To write the retieved filenames to a file, use the the PRINT statement,
    which can also write to a file. See "OPEN .... FOR OUTPUT as ...." for
    that.


    To retrieve the contents of a directory, use DIR$
    [color=blue]
    > Obviously, my question is if and how it can be done.[/color]

    Hmmm ... I don't think can be done, and have no idea to how to do it :-)

    Regards,
    Rudy Wieser



    Comment

    Working...