Rubyのファイル操作
パス名以下の全てのファイルについてループ
Find.find("パス名") do |f|
print f
end
fには"パス名"で指定したところからの相対パスが入ります。
下みたいにディレクトリを開く場合は、fにはファイル名しか入らないので、ちょっと挙動が違います。
Dir.open("パス名").each do |f|
print f
end
src = "img"
dest = "dest"
Dir.open(src).each { |f|
next unless f =~ /(.+)\.(\w+)/
f_l = File.join(src,f)
new_f_l = File.join(dest, $1 + "1E3." + $2)
`convert -pointsize 20 -fill blue -draw "text 100,100 'HD'" #{f_l} #{new_f_l}`
#File.cp(f_l, new_f_l)
#system(s)
#new_f_l = File.join(dest, $1 + "1E2" + $2)
#system(s)
}
require