Jump to content
  • Advertisement
Sign in to follow this  

how to read any filename aslong as it has a specific extension like .png in lua script

This topic is 2895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello i'm trying to read a directory for any file inside the directory that has the .txt extension and then to read that .txt file and find matches of certain occurrences and act upon it

how can i do this in Lua heres some code that is me trying to attempt to do it

require "lfs"
input = io.open("whatevafilename.txt","w")

for content in lfs.dir ("folder") do

for match in lfs.readdir(".txt") do

for match in line:gmatch("test") do

input:write(" somerandomtest ")

for match in line:gmatch("%A") do





When helping me please keep the code above as intact as possible rather then rewriting the hole thing :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!