The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Batch rename using spreadsheet inputs

Batch renaming files using spreadsheet inputs is a highly efficient method for managing large numbers of files. Here’s a practical guide to accomplish this using tools like Excel (or Google Sheets) and a scripting language like Python. The general process involves:


Step 1: Prepare Your Spreadsheet

Create a spreadsheet with at least two columns:

  • Current Filename (e.g., image01.jpg)

  • New Filename (e.g., product01.jpg)

Example:

Current FilenameNew Filename
image01.jpgproduct01.jpg
image02.jpgproduct02.jpg
image03.jpgproduct03.jpg

Save this spreadsheet as a CSV file (e.g., rename_list.csv).


Step 2: Python Script to Batch Rename

Here’s a Python script that reads the CSV and renames files accordingly:

python
import os import csv # Define the path to the folder where the files are located folder_path = '/path/to/your/files' csv_file_path = '/path/to/rename_list.csv' # Read the CSV file with open(csv_file_path, newline='', encoding='utf-8') as csvfile: reader = csv.DictReader(csvfile) for row in reader: old_name = row['Current Filename'] new_name = row['New Filename'] old_path = os.path.join(folder_path, old_name) new_path = os.path.join(folder_path, new_name) if os.path.exists(old_path): os.rename(old_path, new_path) print(f"Renamed: {old_name} -> {new_name}") else: print(f"File not found: {old_name}")

Make sure to:

  • Adjust folder_path and csv_file_path to match your system.

  • Install Python if not already installed (from https://www.python.org/).


Step 3: Run the Script

Save the script as rename_files.py, then run it from your terminal or command line:

bash
python rename_files.py

Notes:

  • Case Sensitivity: Ensure the filenames in the CSV match the actual files exactly, especially on Linux/macOS systems.

  • Backup: Always back up your files before running bulk operations.

  • Permission: Ensure you have write permissions for the target directory.


This method is powerful, accurate, and repeatable—ideal for renaming images, documents, or any batch of files using structured input.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About