Advertisement
Zeehao

clone_hard_disk

Mar 5th, 2024 (edited)
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | Gaming | 0 0
  1. local function get_dir_conts(directory, ign_dirs)
  2.     local contents = {}
  3.     local cmd = "ls " .. directory
  4.     local handle = io.popen(cmd)
  5.     for file in handle:lines() do
  6.         if ign_dirs and ign_dirs[file] then goto continue end
  7.         table.insert(contents, directory .. "/" .. file)
  8.         ::continue::
  9.     end
  10.     handle:close()
  11.  
  12.     return contents
  13. end
  14.  
  15. local ign_dirs = {}
  16. ign_dirs["341"] = true
  17. ign_dirs["421"] = true
  18. ign_dirs["1ff"] = true
  19.  
  20. local src_dir = "/mnt/341/"
  21. local tgt_dirs = get_dir_conts("/mnt", ign_dirs)
  22.  
  23.  
  24. for _, tgt_dir in ipairs(tgt_dirs) do
  25.     print("clone " .. src_dir .. " to " .. tgt_dir)
  26.     os.execute("cp -v -r " .. src_dir .. "/* " .. tgt_dir)
  27. end
Tags: lua Oc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement