vendredi 29 septembre 2017

Removing file using name contains in Ruby

I have written the below code to keep a file that matches the passed in name and removes the rest of the files in the folder.

def removeFiles2(path, namePart)
aft_logger=AFTLogger.new

Dir[path+'/*'].each do |fname|
    break if !(fname.include? namePart)
    else File.delete(fname)
 end
end

end end

But I am getting the below error.

Operation not permitted - Operation not permitted - //CSLK-CISP-81-01/jboss/server/TeamCI_CEPHEUS_OR_R81_Spider_110/home/RoSModule/XML/In/Error: 
Operation not permitted - Operation not permitted - //CSLK-CISP-81-
01/jboss/server/TeamCI_CEPHEUS_OR_R81_Spider_110/home/RoSModule/XML/In/Error tempDevMode.rb line 37 in function test

What am I doing wrong here? Any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire