LoginSignup
3
3

More than 5 years have passed since last update.

録画したアニメをファイルごとに分けよう

Last updated at Posted at 2015-10-18

録画したアニメをファイルごとに分けよう

Chinachuで録画したはいいものの、手動でファイルをタイトルずつ分けていくのは大変なのでrubyを使ってみた

anime.rb
#encoding: utf-8

#Document/recorded というファイルに保存されてるアニメを振り分ける

title = [
        "それが声優",
        "実は",
        "オーバーロード",
        "監獄",
        "ソーマ",
        "下ネタ",
        "モンスター",
        "六花",
        "がっこう",
        "赤髪",
        "空戦"
]

# フォルダの位置
pwd = Dir::pwd + "/recorded"
# ファイルの中身
file = Dir::entries(pwd)

title.each do |e|
        unless system("mkdir #{pwd}/#{e}")
                next
        end

        file.select { |t| /#{e}/ =~ t}.each do |name|
                if system("mv #{pwd}/#{name} #{pwd}/#{e}")
                        puts "OK"
                else
                        puts "Error: #{name}"
                end
        end
end

もう少しうまい書き方あると思うので誰か教えてください (..)

3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3