-
-
Save lqqyt2423/f1eae0ca18e1c61522d9fdbe91f80138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fileutils" | |
# 循环文件夹的块包装 | |
def each_dir(dirname) | |
Dir.open(dirname) do |dir| | |
dir.each do |name| | |
next if name == "." | |
next if name == ".." | |
yield name | |
end | |
end | |
end | |
# 当前执行目录 | |
pwd = Dir.pwd | |
each_dir(pwd) do |filename| | |
pathname = File.join(pwd, filename) | |
if File.directory?(pathname) | |
puts pathname | |
each_dir(pathname) do |subFilename| | |
if /\.mkv$/ =~ subFilename | |
print "\t", subFilename, "\n" | |
tmp_name = File.join(pathname, subFilename) | |
# mv | |
FileUtils.mv tmp_name, pwd | |
end | |
end | |
# rm -r | |
FileUtils.rm_r pathname | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment