Listing the contents of a specific directory

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

Listing the contents of a specific directory

#1 Post by Thundy »

Hey chums. i want to create a list of files in a specific directory in my renpy project. such as images/ I've tried doing it pythonically but keep running into issues with absolute and relative file paths.

I've no doubt that someone has solved this but the search function doesn't appear to be working for me.

any help would be appreciated.

Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

Re: Listing the contents of a specific directory

#2 Post by Thundy »

Ok I figured something out. For those people who want to know how I did it

Code: Select all

listing = renpy.list_files(common=False)
for f in listing:
	if f.startswith("[path of folder you want to search]"):
		print f (or do whatever you want)
 

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Toma