Advertisement
DOGGYWOOF

DOGGY OS Disk copier

Apr 24th, 2024 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. -- Function to copy directories recursively
  2. local function copyDirectory(source, destination)
  3. -- Ensure destination directory exists
  4. if not fs.exists(destination) then
  5. fs.makeDir(destination)
  6. end
  7.  
  8. -- Get list of files and directories in source directory
  9. local items = fs.list(source)
  10.  
  11. -- Loop through each item
  12. for _, item in ipairs(items) do
  13. local sourcePath = fs.combine(source, item)
  14. local destinationPath = fs.combine(destination, item)
  15.  
  16. -- If it's a directory, recursively copy it
  17. if fs.isDir(sourcePath) then
  18. copyDirectory(sourcePath, destinationPath)
  19. else
  20. -- Otherwise, it's a file, so copy it
  21. fs.copy(sourcePath, destinationPath)
  22. end
  23. end
  24. end
  25.  
  26. -- List of directories and programs to copy
  27. local itemsToCopy = {
  28. "/disk/os/",
  29. "/disk/boot/",
  30. "/disk/bootloader/",
  31. "/disk/packages/",
  32. "/disk/security/",
  33. "/disk/error/",
  34. "/disk/pocket/",
  35. "/disk/users/",
  36. "/disk/install-assist",
  37. "/disk/install.lua",
  38. "/disk/server",
  39. "/disk/setup",
  40. "/disk/startup"
  41. }
  42.  
  43. -- Destination directory
  44. local destination = "/disk2/"
  45.  
  46. -- Copy each item in the list to destination
  47. for _, item in ipairs(itemsToCopy) do
  48. if fs.isDir(item) then
  49. -- If it's a directory, copy it recursively
  50. copyDirectory(item, fs.combine(destination, fs.getName(item)))
  51. else
  52. -- If it's a program, just copy it
  53. fs.copy(item, fs.combine(destination, fs.getName(item)))
  54. end
  55. end
  56.  
  57. print("Copying completed.")
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement