7

[Bash] Rename Files in Directory to Lowercase

 2 years ago
source link: http://siongui.github.io/2016/04/25/bash-file-name-to-lowercase/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

[Bash] Rename Files in Directory to Lowercase

April 25, 2016

Convert the name of files in directory to lowercase via Bash script.

#!/bin/bash

# $1 is the directory in which files to be renamed to lowercase
for path in $(find $1 -type f)
do
  dir=$(dirname ${path})
  file=$(basename ${path} | tr "[:upper:]" "[:lower:]")
  mv ${path} ${dir}/${file}
done

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK