#encoding:gbk
def kill_empty_dir(dir)
dir.each do |filename|
next if filename == '.' or filename == '..'
if File.directory?(dir.path + File::SEPARATOR + filename)
kill_empty_dir(Dir.new(dir.path + File::SEPARATOR + filename))
end
end
if Dir.entries(dir.path).size <=2
Dir.delete(dir.path)
puts dir.path
end
end
dir = Dir.new('e:/media')
kill_empty_dir(dir)
Ruby递归删除空目录
最新推荐文章于 2023-05-18 15:14:18 发布