Advertisement
DOGGYWOOF

Untitled

May 27th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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/recovery/",
  31. "/disk/bootloader/",
  32. "/disk/packages/",
  33. "/disk/security/",
  34. "/disk/error/",
  35. "/disk/pocket/",
  36. "/disk/users/",
  37. "/disk/install-assist",
  38. "/disk/install.lua",
  39. "/disk/server",
  40. "/disk/setup",
  41. "/disk/startup"
  42. }
  43.  
  44. -- Destination directory
  45. local destination = "/disk2/"
  46.  
  47. -- Copy each item in the list to the root of the destination
  48. for _, item in ipairs(itemsToCopy) do
  49. local destinationPath = fs.combine(destination, fs.getName(item))
  50.  
  51. if fs.isDir(item) then
  52. -- If it's a directory, copy it recursively
  53. copyDirectory(item, destinationPath)
  54. else
  55. -- If it's a file, just copy it
  56. fs.copy(item, destinationPath)
  57. end
  58. end
  59.  
  60. print("Copying completed.")
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement