Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to copy directories recursively
- local function copyDirectory(source, destination)
- -- Ensure destination directory exists
- if not fs.exists(destination) then
- fs.makeDir(destination)
- end
- -- Get list of files and directories in source directory
- local items = fs.list(source)
- -- Loop through each item
- for _, item in ipairs(items) do
- local sourcePath = fs.combine(source, item)
- local destinationPath = fs.combine(destination, item)
- -- If it's a directory, recursively copy it
- if fs.isDir(sourcePath) then
- copyDirectory(sourcePath, destinationPath)
- else
- -- Otherwise, it's a file, so copy it
- fs.copy(sourcePath, destinationPath)
- end
- end
- end
- -- List of directories and programs to copy
- local itemsToCopy = {
- "/disk/os/",
- "/disk/boot/",
- "/disk/bootloader/",
- "/disk/packages/",
- "/disk/security/",
- "/disk/error/",
- "/disk/pocket/",
- "/disk/users/",
- "/disk/install-assist",
- "/disk/install.lua",
- "/disk/server",
- "/disk/setup",
- "/disk/startup"
- }
- -- Destination directory
- local destination = "/disk2/"
- -- Copy each item in the list to destination
- for _, item in ipairs(itemsToCopy) do
- if fs.isDir(item) then
- -- If it's a directory, copy it recursively
- copyDirectory(item, fs.combine(destination, fs.getName(item)))
- else
- -- If it's a program, just copy it
- fs.copy(item, fs.combine(destination, fs.getName(item)))
- end
- end
- print("Copying completed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement