Guest User

diskcopy

a guest
Sep 28th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. --DiskCopy by PeachMaster
  2. --There are comments for you BigJ :)
  3.  
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. print("DiskCopy by PeachMaster.")
  7. print("Left is input, right is output.")
  8. print("Press ENTER to start the operation.")
  9. read()
  10.  
  11. local count = 1
  12.  
  13. while true do
  14. sleep(5)
  15.  
  16. if disk.isPresent("left") then -- Checks if a disk is present on the left disk drive.
  17. else -- It's not. Kay, error it..
  18. error("A disk is not in the left drive. Please check it.")
  19. end
  20.  
  21. if disk.isPresent("right") then -- Checks again..
  22. else -- It's not. Kay, error it..
  23. error("A disk is not in the right  drive. Please check it.")
  24. end
  25.  
  26. print("Starting disk copy.")
  27.  
  28. --Get every file and directory on the left disk.
  29. local FileList = fs.list(disk.getMountPath("left"))
  30. for f, file in pairs(FileList) do
  31. --Alright, for each one, we will copy it to the right disk.
  32. fs.copy(file, disk.getMountPath("right")
  33.  
  34. end)
  35.  
  36. disk.setLabel("right",  disk.getLabel("left"))
  37.  
  38. --Disk copy completed!
  39. count = count + 1
  40. print(count.." copy created.")
  41.  
  42. end
Advertisement
Add Comment
Please, Sign In to add comment