Thread: CaSe changing command?
hello, may sound odd, know of command rename files , folders in directory lower case?
e.g.:
from
/folder/subfolder/case_sensitive/text.txt
to
/folder/subfolder/case_sensitive/text.txt
??
bash scripting! made , it's working fine
although script *double* tested recommend backing up files before executingcode:#!/bin/bash parent_folder="/home/username/parent_folder" #path parent folder, edit whole script if [ ! -s "$parent_folder" ]; echo "parent folder not exist!\n" exit 2; fi ifs_bak=$ifs ifs=" " file_or_folder in $(find "$parent_folder"/*); file_or_folder_lowercase=$(echo $file_or_folder | tr '[a-z]' '[a-z]') #sending error messages null because mv outputs error if filename same destination name #as result, if have lowercase name not touch output error mv "$file_or_folder" "$file_or_folder_lowercase" 2> /dev/null done ifs=$ifs_bak
edit: works if files have renamed(because if folder has been renamed , has subfiles 'mv' has wrong path.... working on it
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] CaSe changing command?
Ubuntu
Comments
Post a Comment