loop files in folder

P

PBarnes

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 :)
 
S

Severin Ecker

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
 
P

PBarnes

Severin Ecker said:
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

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?
 
S

Severin Ecker

hi!
Thanks for the response, np

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?
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
 
F

Frank Schmitt

Severin Ecker said:
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.

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

HTH & kind regards
frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top