Computing.Net > Forums > Programming > find and replace ultra with extra in files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

find and replace ultra with extra in files

Reply to Message Icon

Name: hadi boy
Date: June 3, 2009 at 21:40:23 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 3, 2009 at 22:19:24 Pacific
Reply:

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


0

Response Number 2
Name: hadi boy
Date: June 7, 2009 at 06:37:48 Pacific
Reply:

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%


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Access VBA CheckBox Contr... Batch files



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: find and replace ultra with extra in files

Find and Replace text in Batch File www.computing.net/answers/programming/find-and-replace-text-in-batch-file/12413.html

Batch find and replace www.computing.net/answers/programming/batch-find-and-replace/15145.html

Find and replace a string in a file www.computing.net/answers/programming/find-and-replace-a-string-in-a-file/19034.html