This is how it was done using ruby
- #!/usr/bin/ruby
- dir = "/mnt/home/suresh"
- files = Dir.entries(dir)
- files.each do |f|
- next if f == "." or f == ".."
- if File.fnmatch('.*',f) then
- puts f
- newname = f + ".olddeb"
- File.rename(f,newname)
- end
- end
Line 5: To ignore the current and parent directories
LIne 6. I wanted to rename only files/directories starting with . (hidden files in unix)
Line 7. prints the current files - just for information
Line 8. the new name is old one with a .olddeb extension
Line 9. Does actual renaming