Search and replace text in windows?

Started by mrapoc, Oct 19, 2008, 16:03:14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mrapoc

Hey guys

im after a tool to search for a certain character or whatever in whichever directory I specify and replace it with something else

In this example I have a lot of "_" in my music collection folder titles for example:

High_Contrast-Tough_Guys_Dont_Dance

i need a program to search, find and replace the _ with a space (ideally)

cheers

Simon

I'd find that useful too, but have never come across anything that can do it.
Simon.
--
This post reflects my own views, opinions and experience, not those of IDNet.

Rik

Everything I've seen works on text within files, Sam, but I can't think of one that works on file names. I'm just wondering, though, whether anything could be done with a batch file?
Rik
--------------------

This post reflects my own views, opinions and experience, not those of IDNet.

Sebby

In one batch file:

for /r c:\filestorename\ %%K in (*.*) do call c:\rename.bat "%%K"
pause
exit


Then in rename.bat:

@echo off
set fname="%~n1"
set ext=%~x1
set fname=%fname:_= %
ren "%~f1" %fname%%ext%
)


Very rough and ready, but tested and working. :)

It could be spruced up a bit to perhaps ask for the directory that contains the files to be renamed, for example.

Rik

Rik
--------------------

This post reflects my own views, opinions and experience, not those of IDNet.

mrapoc

#5
excellent :)

edit:

how do i use it

i put it in my music directory and as follows

1st batch:

for /r D:\My Music\ %%K in (*.*) do call D:\My Music\rename.bat "%%K"
pause
exit


rename batch:

@echo off
set fname="%~n1"
set ext=%~x1
set fname=%fname:_= %
ren "%~f1" %fname%%ext%
)

Sebby

You probably need to do "D:\My Music\" and "D:\My Music\rename.bat" because of the spaces.

Dopamine

I use the freeware Bulk Rename Utility, which amongst many options has a "replace x with y" function.

http://www.bulkrenameutility.co.uk/Main_Intro.php

Sebby

That's much better than my solution, thanks. :thumb: