Here's one way to do it:
Code:
ruby -e 'ARGV.each {|f| next unless File.file?(f); next if f =~ /\./; File.rename(f, f+".txt") }' *
This will rename only plain files (not directories, symlinks, or devices) whose names do not contain a "." character. It correctly handles filenames with spaces. It examines every file in the current working directory.
The previous poster's code would rename every file and directory in the current working directory, except filenames with spaces, which it would choke on.
If you followed that advice, you may now have a directory full of files with names like "file.txt.txt" and "movie.avi.txt". You could fix that problem by running this command:
Code:
rename 's/\.txt$//' *
Bookmarks