Advertisement
Pirnogion

glue/zipper

Feb 8th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. local InputFiles     = nil
  2.  
  3. local OutputFile     = nil
  4. local OutputFileData = nil
  5.  
  6. local InputFile      = nil
  7. local InputFileData  = nil
  8.  
  9. local Info = "Input"
  10.  
  11. term.clear()
  12. term.setCursorPos(1, 1)
  13.  
  14. print("Glue. Version 1.")
  15.  
  16. write("Please enter output filename: ")
  17. OutputFile = read()
  18.  
  19. while true do
  20.     term.clear()
  21.     term.setCursorPos(1, 1)
  22.    
  23.     print(Info)
  24.     write("Please enter input filename or foldername: ")
  25.     InputFile = read()
  26.    
  27.     if (fs.isDir(InputFile)) then InputFiles = fs.find(InputFile .. "/*") else InputFiles[1] = InputFile end
  28.    
  29.     if (InputFile == "stop") then break end
  30.    
  31.     for i = 1, #InputFiles, 1 do
  32.         InputFile = InputFiles[i]
  33.         if (fs.exists(InputFile)) then
  34.             outfile = fs.open(OutputFile, "a")
  35.             infile  = fs.open(InputFile,  "r")
  36.            
  37.             InputFileData = infile.readAll()
  38.            
  39.             outfile.writeLine("")
  40.             outfile.writeLine("<GluePath>" .. InputFile)
  41.             outfile.write(InputFileData)
  42.            
  43.             outfile.close()
  44.             infile.close()
  45.            
  46.             Info = Info  .. " : " .. InputFile
  47.         else print("File not found.") sleep(1) end
  48.     end
  49. end
  50.  
  51. term.clear()
  52. term.setCursorPos(1, 1)
  53.    
  54. print("Files glued!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement