Rename All Files in Linux--- #2

Rename All Files in Linux

 This guide will show you how to rename all files and directories names to lowercase in Linux.

There are several ways to achieve this, but we’ll explain two of the most efficient and reliable methods. For the purpose of this guide, we have used a directory named Files which has the following structure:

# find Files -depth 
 

Using find, xargs and rename Commands Together

rename is a simple command line utility for renaming several files at once in Linux. You can use it together with find utility to rename all files or subdirectories in a particular directory to lowercase as follows:

$ find Files -depth | xargs -n 1 rename -v 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; 

Explanation of options used in the above command.
  • -depth – lists each directory’s contents before the directory itself.
  • -n 1 – instructs xargs to use at most one argument per command line from find output.
Sample output after renaming files and subdirectories to lowercase in Files directory.

Comments

Popular posts from this blog

4 Best IDEs for C/C++ Programming or Source Code Editors on Linux #10

4 Best Linux Boot Loaders -- #5

3 Top Open Source Artificial Intelligence Tools for Linux --- #4