From b481e0ad1f9a8ddc39713a8a17de47761df82924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Sat, 14 Oct 2017 12:19:02 +0200 Subject: [PATCH] how can it be so hard to count the number of files in a directory? --- update.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/update.rb b/update.rb index a3b2752..4595542 100644 --- a/update.rb +++ b/update.rb @@ -6,11 +6,9 @@ log_dir = LOG_DIR users.each do |user| size = `du -B1 #{shot_dir}#{user}/ | awk {'print $1'} | head -n 1` - count = `find #{shot_dir}#{user}/ -maxdepth 1 -type f | wc -l | head -n 1` + count = Dir["#{shot_dir}#{user}/*"].length - [size,count].each do |x| - x.delete! "\n" - end + size.delete! "\n" File.open("#{log_dir}/#{user}.log","a") do |f| f << "#{Time.now.to_i} #{count} #{size}\n"