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
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
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%
Summary: I need to figure out a method to find and replace text within a text file. I have a file named, "myfile.txt" that has the following; testing=1 database=500 rules=30 I want the batch file to find datab...
Summary: Hello, I was trying to create a batchfile that will perform find and replace for a user defined string (both for find and replace) within a group of files. I havent had much luck. Any help would be gr...
Summary: What does it mean? I have a file which contains the name of various SQL scripts, like... T1.sql; inside these sql scripts i have a commit statement Do you mean that the file contains nothing but the ...