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 namedFiles
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.
Files
directory.
Comments