Advertisement
BombBloke

Kenshi Workshop Mod Mover

Sep 6th, 2022
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | Source Code | 0 0
  1. -- Moves Kenshi mods out of your Steam workshop folder and in to your actual mods folder.
  2.  
  3. -- Save this as a text file in your Kenshi folder, name it as "grabWorkshopMods.lua" or somesuch,
  4. -- double click to run.
  5.  
  6. -- You can stick it somewhere else if you modify the WorkshopFolder and ModsFolder values.
  7.  
  8. -- Lua VM required, I use 5.1 and can't tell you if other versions will work:
  9. -- https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/luaforwindows/LuaForWindows_v5.1.4-46.exe
  10.  
  11. ------------------------------------------------------------
  12.  
  13. local WorkshopFolder = "../../workshop/content/233860"
  14. local ModsFolder = "mods"
  15.  
  16. ------------------------------------------------------------
  17.  
  18. require "lfs"
  19.  
  20. if WorkshopFolder:sub(2,2) ~= ":" then WorkshopFolder = lfs.currentdir() .. "/" .. WorkshopFolder end
  21. if ModsFolder:sub(2,2) ~= ":" then ModsFolder = lfs.currentdir() .. "/" .. ModsFolder end
  22.  
  23. for entry in lfs.dir(WorkshopFolder) do if entry ~= "." and entry ~= ".." then
  24.     local attribs = lfs.attributes(WorkshopFolder .. "/" .. entry)
  25.    
  26.     if attribs and attribs.mode == "directory" then
  27.         local modname
  28.        
  29.         for filename in lfs.dir(WorkshopFolder .. "/" .. entry) do
  30.             if filename:lower():sub(-4) == ".mod" then
  31.                 modname = filename
  32.                 break
  33.             end
  34.         end
  35.        
  36.         if modname then os.rename(WorkshopFolder .. "/" .. entry, ModsFolder .. "/" .. modname:sub(1, #modname - 4)) end
  37.     end
  38. end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement