Change Filenames by Replacing Spaces With Underscores

Vikas Medhekar
Updated on

Having a good file naming convention can save you a lot of time and effort. While manually renaming a few files is doable, the task can get quite tedious if you have hundreds or thousands of files. In this article, we’ll discuss why naming files properly is crucial and how you can easily rename files in batches.

Replace space with underscore using Easy File Renamer

Easy File Renamer is 100% safe. It is digitally signed and a safe download.

Why Could Batch File Renaming Be Needed? 

If you share or sync files regularly, it is likely that you have a lot of files with random and unclear filenames. It happens often that when you copy and paste files from one location to another, there already exists a file with that name and hence, you end up generating new file names that consist of suffixes like -Copy(2) or -Copy(3). Overtime, this could create a huge clutter all across your computer. This could make it difficult for you to find and locate files later.

How to Replace Spaces With Underscores?

Now let’s look into a few methods that you can use to rename files in bulk.

Easy File Renamer

This one is by far the easiest and quickest way to rename your files in bulk and replace spaces with underscores. Easy File Renamer (EFR) allows users to batch rename files from different folders at the same time. This can save your time significantly. With EFR, you can:

  • Securely rename thousands of files together
  • Select from various renaming patterns
  • Copy or relocate large files across different locations 
  • Edit music tags 
  • Get a free complimentary license to other tools by the same company (including one for Cloud File Renamer that can be used to rename files on OneDrive, Google Drive, Dropbox, Amazon S3) 

Renaming Patterns

With Easy File Renamer, you can rename files using several different automatic patterns. For example, you can add a prefix/suffix, remove text, replace text, insert text at a particular position, change to uppercase/lowercase, and even add numberings. In this particular case, you can use the replace text option to replace spaces with underscores. 

Procedure

Using Easy File Renamer is a piece of cake. Once you have downloaded and installed it, follow these simple steps:

  • Head to Files and click on Add Files.
  • Select the files that you wish to rename. You can select as many as you want. 
  • Go to Select Rule and select Replace.
  • Type space by hitting the spacebar in the Find section.
  • Type an underscore in the Replace section. 
  • Select the Replace All option.
  • Click on Add Rule. You can also add multiple rules.
  • Hit the Rename button to make the final changes.

And that’s all! With just a few simple steps, you can easily batch rename files and replace spaces with characters like underscores. 

Windows Explorer 

  • Open This PC.
  • Head to the folder where you want to rename files.
  • Click on the View tab from the toolbar at the top.
  • Navigate to Layout and set it to Details.
  • Select the first file that you want to rename, click on it and continue holding the Shift key until you reach the last file that you wish to rename.
  • Hit the F2 key and then type a new name for your files. 
  • Hit Enter to make the changes.

Windows PowerShell 

Using PowerShell to rename files can be quite a daunting task if you are not familiar with command line tools. Although this method is not recommended, let’s look into how it works:

  • Click on Start
  • Type PowerShell and open Windows PowerShell
  • Select Run as Administrator
  • Enter the directory path. For example:

    CD C:\Users\John\Documents
  • Now, you can use the following command to replace all spaces in the filenames with underscores:

    get-childitem *.* | foreach { rename-item $_ $_.Name.Replace(” “, “_”) }
  • The command above would work for all file types. If you want to replace spaces in only specific file types, use this command instead:

get-childitem *.docx | foreach { rename-item $_ $_.Name.Replace(” “, “_”) }

  • Exit once you’re done

VisualBasic Scripts

Instead of typing the above mentioned commands into the PowerShell, you can also create a VisualBasic script to automate the process. To do so: 

  • Open Notepad.
  • Write the necessary commands
  • Save file as BatchRename.VBS
  • Exit notepad
  • To run, double click and open the file later

Leave a Reply

Your email address will not be published. Required fields are marked *