Bash: Rename all files in current directory to lowercase

Just some code i used to rename my holiday pictures to lowercase.

find ./* -type f -maxdepth 0 | while read upName; do loName=`echo "${upName}" | tr '[:upper:]' '[:lower:]'`; mv "$upName" "$loName"; done

find lists all files in current directory. -type f lists only files, not directorys.

The while loop iterates over the file list.

echo | tr makes the filename variable lowercase.

mv finally moves the file.

Thanks to Veikko for the maxdepth hint.

Related posts:


 
 
 

Ein Kommentar zu “Bash: Rename all files in current directory to lowercase”

  1. Veikko 25. Mai 2011 um 09:25

    If you have subdirectories than they will get listed by the find command as well.
    That is not what the heading describes.

    find ./* -type f -maxdepth 0

    will only show the files of the current directory and no subdirectories