Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##
- ## "LowerIt"
- ##
- ## Original code found here: http://www.linuxjournal.com/content/convert-filenames-lowercase
- ## Modified by Maiya78 to change directory names, to work recursively, and to support unicode filenames on GNU systems. I also copyedited the comments. :3
- ##
- ## From the current directory, recursively convert to lower case all file and directory names
- ## Should ask for verification before overwriting an existing file.
- ##
- ## ------------------------------------------------------------------------------------------------------------
- ## Clean up aliases
- unset pwd && unset export && unset cd && unset echo && unset ls && unset
- ## Make sure we're in the right directory
- export strDir=$(pwd)
- cd $strDir
- echo "Entering current directory: "$strDir
- ## Need to make a loop or something here that repeats this for every subdirectory ad nauseum
- ## Show the user what's in the current directory pre-edit
- echo "
- Current directory before edit: " && ls -a
- ## Start the editing loop
- for strItem in $(ls -a)
- do
- ## Save the computer some breath on . and ..
- # if [[ $strItem != '.' || '..' ]]; then
- # continue
- # fi
- ## Set a variable equal to the lowercased vesion of the original filename
- strLowerCasedItem=$(echo $strItem | sed 's/[[:upper:]]*/\L&/')
- ## If this variable is the same as the original, then the original was already lowercased, so we skip it.
- if [[ $strLowerCasedItem != $strItem ]]; then
- mv -i $(echo $strDir'/'$strItem) $(echo $strDir'/'$strLowerCasedItem)
- fi
- done
- ## Show the user what's in the current directory post-edit
- echo "
- Current directory after edit: " && ls -a
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement