find and replace ultra with extra in files

June 3, 2009 at 21:40:23
Specs: Windows XP
find and replace "ultra" with extra in files and forders names
============================
hi
i want a batch file that search for all files and forlders for find and replace "ultra" to "extra" in folders and files names
can you help me?
thanks

See More: find and replace ultra with extra in files

Report •


#1
June 3, 2009 at 22:19:24
if you have Python on Windows

import os
import  fileinput
path=os.path.join("c:\\","test")
for r,d,f in os.walk(path):
    for files in f:
        if "ultra" in files:
            newfile=files.replace("ultra","extra")
            os.rename( os.path.join(r,files) , os.path.join(r,newfile) )
      

save the script as myscript.py and on command line
c:\test> python myscript.py


Report •

#2
June 7, 2009 at 06:37:48
ok i write something myself but it's not working
can you help me to make it right?

@echo off
for /f "delims=" %%a IN ('dir *ultra*.??? /s /b /on') do call :rename "%%a"
:rename
set string=%1
set string=%string:ultra=extra%
ren %1 %string%


Report •

Related Solutions


Ask Question