By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

loop files in folder

P: n/a
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 :)
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> 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
Jul 19 '05 #2

P: n/a
"Severin Ecker" <se****@gmx.at> wrote in message news:<3f***********************@aconews.univie.ac. at>...
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


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?
Jul 19 '05 #3

P: n/a
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
Jul 19 '05 #4

P: n/a
"Severin Ecker" <se****@gmx.at> writes:
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.


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
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.