TangentFox

move-non-images.lua (Windows-specific)

Jan 27th, 2021
1,426
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local image_types = { ".mp4", ".png", ".jpg", "jpeg", ".gif", "webm" }
  2.  
  3. os.execute("dir /w /b > files.txt") -- Windows-specific
  4. os.execute("mkdir non-image")
  5.  
  6. local file = io.open("files.txt")
  7.  
  8. for line in file:lines() do
  9.   local keep = false
  10.   for _, t in ipairs(image_types) do
  11.     if line:sub(-4) == t then
  12.       keep = true
  13.       break
  14.     end
  15.   end
  16.   if not keep then
  17.     os.execute("move \""..line.."\" non-image/")
  18.   end
  19. end
  20.  
  21. os.remove("files.txt")
  22.  
RAW Paste Data