################################################################################# # 音楽ファイルの中で曲番が付いてないファイルが存在するフォルダを探し、 # その結果をdir-list.txtに記述。 # なお途中のディレクトリにはファイルが無いと想定している # # 「>ruby all_trucklist.rb D:\mp3」のように実行 ################################################################################# myroot = ARGV[0] $f1 = open("dir-list.txt","w") #保存するファイル名 def listall(cdir) check = 0 #曲番がついたファイルがあるか判定用の変数 Dir.foreach( cdir ) do |file| # 中身を一覧 next if /^\.+$/ =~ file # 上位ディレクトリと自身を対象から外す newfile = cdir.sub(/\/+$/,"") + "/" + file #ファイルをフルパスにして if FileTest.directory?(newfile) then #ディレクトリかどうかテストして check = 1 #★途中のディレクトリは名前変換の対象外 listall(newfile) #ディレクトリの場合、再帰で実行 else if /01/ =~ file or /02/ =~ file # 01や02を含んだファイルが存在するか? check = 1 end end end if check == 0 $f1.puts cdir end end listall(myroot) $f1.close