'Renaming a file and remove 'dot' and replace it with' _'

I have set of files in a folder with name like abcd.15678 I want to remove the . and replace it with _

Pls suggest the windows command to do this



Solution 1:[1]

This solution is reposted from How to Batch Rename Files in Windows: 4 Ways to Rename Multiple Files by Chris Hoffman

PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.

Open PowerShell ISE

First of all, open Powershell ISE and then navigate to the directory (folder) that has the files and folders you'd like to rename by using this command:

cd "C:\your\directory\"

Navigate to your folder

The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.

After you launch PowerShell ISE, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.

For example, let’s say we don’t want the dot character in our file names – we’d rather have an underscore instead.

The following command lists the files in the current directory and pipes the list to Rename-Item. Rename-Item replaces each dot character with an underscore.

Dir | Rename-Item –NewName { $_.name –replace ".","_" }

Consult Microsoft’s documentation on the Rename-Item commandlet if you want help performing other, more advanced operations.

Solution 2:[2]

There isn't a windows command to do this. You should consider writing a script of some sort that obtains a directory listing and enumerates through each entry: changes the dot to an underscore, and calls the windows rename command appropriately.

Solution 3:[3]

Actually this should work :

Dir | Rename-Item –NewName { $_.Name.Replace(".","_") }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Innes
Solution 2 mah
Solution 3 Bartosz Konieczny