Dir.chdir("/your/directory/here") #changes the current working directory getFiles=`ls *.rb` #passes this command to the shell fileList=getFiles.split(/\n/) #creates an Array separated with \n fileList.length.times{ #opening of a block fileName=fileList.pop #pops the first item out of the Array ############################# fileA=File.open(fileName,"r") #opens the file thats in fileName as read only doc=fileA.read #reads the file into the doc string fileA.close #closes the file ############################# doc.gsub!(/a/,"@") #replaces "a" with "@" in the doc string ############################# fileB=File.open(fileName,"w") #deletes and opens a the file in fileName fileB.write(doc) #writes the contents of doc into the file fileB.close #closes the file ############################# } #closing block #Copyright James McCarthy 21/08/2004