Trying to delete file using FileUtils not working

I have a directory (dir_menu) that contains the following files:

I’m trying to remove the two files with the “.htmt” extensions using the
following line of code:

Dir.foreach(“dir_menu”) {|f| FileUtils.rm(f) if(f.include? “.htmt”)}

I keep getting the following error:

Errno::ENOENT (No such file or directory - menu_lesson.htmt):

Obviously it finds the file otherwise it wouldn’t list the filename in
the error message. What am I missing here?

Nevermind. Figured it out. Need to take a different approach. Ended
up doing the following for anyone else who wants to know.

FileUtils.rm Dir.glob("*.{htmt,jst}")

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