If you’ve ever received a collection of files with uppercase extensions (such as .PDF, .JPG, or .TXT), you may have discovered that some applications, scripts, or web servers expect lowercase extensions instead. Fortunately, macOS makes it easy to rename files in bulk directly from the Terminal.
In this article, I’ll show you how to recursively rename all .PDF file extensions to .pdf throughout an entire directory structure.
Why Convert File Extensions to Lowercase?
While macOS itself is generally case-insensitive, many Linux servers, web servers, and automation scripts are not. Converting file extensions to lowercase can help:
- Maintain consistency across your files.
- Prevent broken links on web servers.
- Improve compatibility with scripts and applications.
- Standardize large collections of files.
Step 1: Open Terminal
Launch Terminal.app from:
Applications → Utilities → Terminal
Step 2: Navigate to Your Directory
Type:
cd
After typing cd, drag the folder containing your files into the Terminal window. macOS will automatically insert the full path.
Press Enter.
To verify you’re in the correct location, run:
ls
This displays the files and folders in the current directory.
Step 3: Rename All Uppercase PDF Extensions
Run the following command:
find . -type f -name "*.PDF" -exec sh -c 'mv "$1" "${1%.PDF}.pdf"' _ {} \;
What This Command Does
find .searches the current directory and all subdirectories.-type flimits the search to files.-name "*.PDF"finds files ending in.PDF.mvrenames each file.${1%.PDF}.pdfremoves the uppercase extension and replaces it with the lowercase version.
For example:
Before:
Document1.PDF
Invoice.PDF
Manual.PDF
After:
Document1.pdf
Invoice.pdf
Manual.pdf
Search a Different Directory
Instead of searching the current directory (.), you can specify another location:
find /path/to/folder -type f -name "*.PDF" -exec sh -c 'mv "$1" "${1%.PDF}.pdf"' _ {} \;
Replace /path/to/folder with the directory you want to process.
Final Thoughts
This simple one-line command is an excellent way to clean up large collections of files without manually renaming each one. If you’re organizing documents before uploading them to a web server, archiving files, or simply enforcing consistent naming conventions, this method can save a tremendous amount of time.
Once you become comfortable with the find command, you can easily adapt it to rename other file extensions such as .JPG, .PNG, .DOCX, and many more.