用PHP代理下载小说的时候,html扩展名全部被Google的浏览器保存成.php。这个很讨厌。
用Lua写个脚本来解决吧。
require'lfs'
local sep = "//"
function renamedir(path)
local i = 1 -- 这里是upvalue,每个子目录都不一样的哦,都从1开始数
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..sep..file
print ("/t=> "..f.." <=")
local attr = lfs.attributes (f)
--assert (type(attr) == "table")
if attr.mode == "directory" then
renamedir(f)
else
if f:find('php') then
cmd = [[ren "]]..f..[[" ]]..[["txt]]..i..[[.html"]]
i = i + 1
print (cmd)
os.execute(cmd)
end
end
end
end
end
renamedir('.')