loop files in folder

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

    loop files in folder

    I need to write a program that will read the contains of a folder
    and output it into a text file. the folder will contain files with
    extensions
    ..000 .001 .002... and so on, plus many .txt, .tif, and .htm files
    basically the output text file as to be in the following format;

    Y
    1
    1
    1
    filename.000


    y
    2
    filename.001


    y
    4
    filename.tif


    y
    3
    filename.txt


    n

    the first 5 lines will always be the same, after that it as to add
    'y','2' if the extension is .00#
    'y','3' if the extension is .txt or .htm, and 'y','4' if the extension
    is .tif or .jpg

    any ideas?
    thanks :)
  • Severin Ecker

    #2
    Re: loop files in folder

    > I need to write a program that will read the contains of a folder

    afaik there are only system-calls for directory functions (looping through
    all the files in a dir, c++ only handles files)
    try the msdn-site for windows, or the manpages for linux/unix and you should
    find what you need.

    regards,
    sev


    Comment

    • PBarnes

      #3
      Re: loop files in folder

      "Severin Ecker" <secker@gmx.a t> wrote in message news:<3f9ab97c$ 0$33210$3b214f6 6@aconews.univi e.ac.at>...[color=blue][color=green]
      > > I need to write a program that will read the contains of a folder[/color]
      >
      > afaik there are only system-calls for directory functions (looping through
      > all the files in a dir, c++ only handles files)
      > try the msdn-site for windows, or the manpages for linux/unix and you should
      > find what you need.
      >
      > regards,
      > sev[/color]

      Thanks for the response,

      I don't need the script to see the folder itself, I will CD to the
      folder and run the
      Script on the files in the folder, can I work with this?

      Comment

      • Severin Ecker

        #4
        Re: loop files in folder

        hi!
        [color=blue]
        > Thanks for the response,[/color]
        np
        [color=blue]
        > I don't need the script to see the folder itself, I will CD to the
        > folder and run the
        > Script on the files in the folder, can I work with this?[/color]
        if the script simply gets a list of filenames (e.g. through stdin) there's
        no problem with that solution.
        it's up to you how you generate that list,.. eighter you make the input by
        hand, or use the output of a prog that lists all the files in the folder.

        hope, this helps.
        regards,
        sev


        Comment

        • Frank Schmitt

          #5
          Re: loop files in folder

          "Severin Ecker" <secker@gmx.a t> writes:
          [color=blue][color=green]
          > > I need to write a program that will read the contains of a folder[/color]
          >
          > afaik there are only system-calls for directory functions (looping through
          > all the files in a dir, c++ only handles files)
          > try the msdn-site for windows, or the manpages for linux/unix and you should
          > find what you need.[/color]

          AFAIK the boost filesystem library does exactly this in a system-independent
          way - check www.boost.org

          HTH & kind regards
          frank

          --
          Frank Schmitt
          4SC AG phone: +49 89 700763-0
          e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com

          Comment

          Working...