Skip to content

Instantly share code, notes, and snippets.

@kiwofusi
Created July 6, 2014 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiwofusi/1c66014cface1ac22290 to your computer and use it in GitHub Desktop.
Save kiwofusi/1c66014cface1ac22290 to your computer and use it in GitHub Desktop.
ファイル数カウント
# coding: utf-8
require 'date'
def count_file(count_dir, log_file)
# ファイルの先頭に書き足すのがスパッとできないのでこういう書き方に
open(log_file, "a").close()
open(log_file, "r+") do |f|
f.puts (DateTime.now+1).strftime("%Y/%m/%d") + "," + Dir::glob(count_dir + "/**/*.*").count.to_s
f.print open(log_file).read
end
end
count_dir = "C:/どこどこ"
log_file = "C:/どこどこ/ほげ.csv";
count_file(count_dir, log_file)
フォルダ内のファイル数を「(日付),(ファイル数)」で書き出す。
未読数的な意味でログをとりたかったので。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment