Concat set of files

Hi ,

I have a set of files with file names like -
TIN-ABC.html , tmp-TIN-ABC.html
TIN-PQR.html , tmp-TIN-PQR.html

I would like to append tmp files in main and delete tmp files within the
directory.
append tmp-ABC.html file to ABC.html , delete tm-ABC.html

not sure whats the simplest way under the directory loop without opening
files.


Coding like this -
Dir.glob(“C:/test/tmp-TIN-*.html”) do |f|
???
FileUtils.rm(f)
end

Thanks

hi dabba dabba,

maybe the Find module will help -
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/find/rdoc/Find.html -

it’s great for recursively scanning directories and finding files
without opening either. it works something like:

Find.find(directory){|path| do_something(path)}

you could then use the File class to do whatever you need to do…

hth-

j

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs