Batch File to replace one character in a filename with another character
Consider using a free GUI app to hold your hand: http://www.bulkrenameutility.co.uk/Main_Intro.php
If you must this yourself with a batch file, be super careful! Batch scripts don't have an "undo" button. If you execute your bat script which applies to all files recursively under somewhere like C:
, you've just renamed every file on your computer and it will immediately stop working and fail to boot. You'll have to do an full OS reinstall. Always have a backup!
First you'll have to decide do you want the batch file to work on a single file? To work on all files in a directory? Or do have it done recursively (all files/folders under a directory). Here are some pointers:
Batch file to replace all underscores _
with the letter M
to all files in current directory
Put this in a batch file named change_underscores_in_this_directory.bat
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
set file=%%a
ren "!file!" "!file:_=M!"
)
Execute it, and all the files in that directory with an underscore will be changed to an 'M'.
Use a Batch File to replace spaces with nothing (removing the spaces):
https://stackoverflow.com/questions/11270453/how-to-remove-spaces-from-file-names-in-bulk
Use a Batch File to replace spaces with underscores, Recursively:
https://stackoverflow.com/questions/1613644/how-to-replace-names-recursively-via-windows-batch-operation