Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 08:39 PM
PBarnes
Guest
 
Posts: n/a
Default 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 :)
  #2  
Old July 19th, 2005, 08:39 PM
Severin Ecker
Guest
 
Posts: n/a
Default 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


  #3  
Old July 19th, 2005, 08:39 PM
PBarnes
Guest
 
Posts: n/a
Default Re: loop files in folder

"Severin Ecker" <secker@gmx.at> wrote in message news:<3f9ab97c$0$33210$3b214f66@aconews.univie.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?
  #4  
Old July 19th, 2005, 08:40 PM
Severin Ecker
Guest
 
Posts: n/a
Default 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


  #5  
Old July 19th, 2005, 08:43 PM
Frank Schmitt
Guest
 
Posts: n/a
Default Re: loop files in folder

"Severin Ecker" <secker@gmx.at> 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles