6 examples for rename
# strip extension from all files matching *.bak rename -x *.bak # strip the .bak extension from all files (by regex) rename 's/\.bak\z//' *
# Change "ddmm" format to "dd_mm" using variable substitution rename 's/(\d{2})(\d{2}).jpeg/$1_$2.jpeg/' *
# rename beginning of files (with .txt extension, in this example) rename 'new_file' 'old_file' *.txt
# Rename all spaces in a file to '_'(underscores) making them more Unix-y... # think of s/\s as s/(substitute) \s(spaces) /(with) '_'(underscores) /globally(/g), # while * *(selects all files with spaces in them). rename -v -n 's/\s/_/g' * * # The -v is for verbosity and printing the results of the operation to the screen, # and -n or -nono is an optional option for testing a rename, before actually renaming. # If your satisfied you can remove the -n and make the changes.
# use the find command to select only directories(-type d), in the current directory only(-maxdepth 1); # and substitute all spaces for underscores globally(/g). find ./ -type d -maxdepth 1 | rename -v 's/\s/_/g'