Created
July 6, 2014 02:01
-
-
Save kiwofusi/1c66014cface1ac22290 to your computer and use it in GitHub Desktop.
ファイル数カウント
This file contains 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
# 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) |
This file contains 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
フォルダ内のファイル数を「(日付),(ファイル数)」で書き出す。 | |
未読数的な意味でログをとりたかったので。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment