Removing the First 5 Characters from the File Names

Renaming hundreds of files at once can be a repetitive task. If you need to strip specific characters from your file names, there are better ways to accomplish it. In this tutorial, we’ll discuss a few methods.

Product Spotlight: Easy File Renamer (EFR) — Rename documents, files and folders (also remove characters from file names) in bulk easily. EFR is made by our company Sorcim Technologies. It follows Google Software principles. Download it here.

Method 1: Using PowerShell

PowerShell is a command-line tool that lets you automate repetitive tasks on your system. You may rename hundreds of thousands of files with one command. Unlike other File Explorer methods, PowerShell gives you better control over how you want to rename your files. You may customize the command depending on your needs.

  1. Open File Explorer.
  2. If the files you want to rename are located in multiple directories or drives, move them into a single folder. For example, if your files are located in D:\Folder1, D:\Folder2, D:\Folder4, move them to a single folder D:\FilesForRenaming.
  3. Type PowerShell in the Search Box on your Taskbar.
  4. Right-click Windows PowerShell from the results and select Run as Administrator.
  5. Use one of the following commands depending on your requirement, and press Enter:

A. To trim the first 5 characters from file names, use the following command:

Syntax:

CD <Folder Path>

get-childitem *<Extension> | rename-item -newname { [string]($_.name).substring(No of characters to trim) }

Example:

CD D:\FilesForRenaming

get-childitem *.* | rename-item -newname { [string]($_.name).substring(5) }

B. To trim first 5 characters from only JPEG image files, use the following command:

Syntax:

CD <Folder Path>

get-childitem *<Extension> | rename-item -newname { [string]($_.name).substring(No of characters to trim) }

Example:

CD D:\FilesForRenaming

get-childitem *.jpeg | rename-item -newname { [string]($_.name).substring(5) }

C. To trim the last 5 characters from file names, use the following command:

Syntax:

Get-ChildItem “<Folder Path>” | rename-item -newname { $_.name.substring(0,$_.name.length-<No of characters to trim>) } 

Example:

Get-ChildItem “D:\FilesForRenaming” | rename-item -newname { $_.name.substring(0,$_.name.length-5) } 

Note:

  • It’s a good practice to enter file paths into double-quotes to avoid execution errors. If any file path contains spaces, PowerShell will display an error. To avoid such a situation, enter file paths into double-quotes.

Method 2: Using an Automated Solution (Easy, Quick & Safe)

Even though you can rename your files without any third-party tools, there are many restrictions. For instance, you may not be able to define custom rules to create unique file name patterns. It is also not possible to apply multiple rules at the same time to your files.

This is where a third-party solution Easy File Renamer can be helpful. 

  1. Install and open the Easy File Renamer tool.
  2. Switch to the System Renamer tab.
  3. Click on Files > Add Files.
  4. Select the files you want to rename. You may select multiple files all at once.
  5. To add the files, click on the Open button.
  6. Once you’ve added your files, Easy File Renamer will display basic details about each file.
  7. Now, select a renaming pattern from the left side panel. For the purpose of this tutorial, select the Trim Text option. In the Length box, type 5 and select Start of the nature to delete the first 5 characters.
  8. Click on Add Rule.
  9. Finally, click on the Rename button to proceed.

Method 3: Rename One File At A Time Using File Explorer

Although Windows does not include any in-house functionality to rename your files, you may use a combination of keyboard keys together to quickly rename your files. These keyboard shortcuts will help you to navigate through different files easily and rename them one by one, or all at once. The drawback? You can only rename files stored in a single folder at once. If you’ve multiple folders to rename, you’d need to repeat it over for each folder.

  1. Click on the File Explorer icon on your Taskbar.
  2. Navigate to the folder to rename the containing files.
  3. Right-click a file you want to rename and select the Rename option.
  4. Type a name for your file.
  5. Instead of pressing Enter, press the Tab key to jump over to the next file in sequence.
  6. As soon as you press the Tab key, Windows will rename the first file and allow you to rename the second file. Type a name for the second file and again, press the Tab key to jump over to the next file.
  7. Repeat over the same process for other files until all the files are completely renamed.

Method 4: Rename All Files In A Folder Using File Explorer

Another method is to rename all files at once in each folder using File Explorer. File Explorer provides an easy way to rename all files using keyboard shortcuts.

  1. Open File Explorer.
  2. Click on the View tab on the Ribbon interface and make sure that the Details view is selected.
  3. Navigate to the folder containing your files.
  4. Press Ctrl + A to select all the files.
  5. Type a common name for your files. For example- cat_photo.
  6. Press Enter and Windows will automatically rename all files with cat_photo and an incremental number. For example: cat_photo.jpg, cat_photo (2).jpg, cat_photo (3).jpg, etc.