/data/picture/2015/というディレクトリにある*.JPGに該当するファイル一覧を出力するプログラムです。

ソースコード

Dir.chdir("/data/picture/2015/")
Dir.glob("*.JPG") do |f|
    p f
end

実行結果

% ruby list.rb
"DSC_0068.JPG"
"DSC_0069.JPG"
"DSC_0070.JPG"
"DSC_0071.JPG"
"DSC_0072.JPG"
"DSC_0073.JPG"
"DSC_0074.JPG"
"DSC_0075.JPG"
"DSC_0076.JPG"
"DSC_0077.JPG"
"DSC_0078.JPG"
%

  添付編集
Last-modified: 2015-02-06 (金) 23:14:53 (3367d)