Click here to Skip to main content
15,867,997 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello erveryone.
i have a bach script to make.
i have huge folder whith name is number , inside the folder we have 2 folder
saw ans welding.
i need to search all folder whit name welding and rename all file inside to change extention inside Welding folder
ex: 0011121.01 to 001112101.wlg

What I have tried:

cd C:\Users\Denis\Desktop\cedule

Set soudeuse=%%A

forfiles /S /M  *.* /C "cmd /c rename @file @fname.wld"
Posted
Updated 6-Sep-22 2:10am
Comments
Richard MacCutchan 6-Sep-22 7:51am    
OK, see below.
denis larocque 6-Sep-22 8:07am    
that rename all of my file to wld but not only one in welding in saw to, and in same time rename my batch scrtp to .wld ....

1 solution

Add the following to a .cmd file and then run it:
Shell
FOR /D %%d in (*) do (
    cd %%d
    FOR /D %%w in (welding) do (
        cd %%w
        forfiles /S /M  *.* /C "cmd /c rename @file @fname.wld"
        cd ..
    )
    cd ..
)

Note: Create a test directory first to make sure the script works for your configuration. Do not test it on your live files.
 
Share this answer
 
Comments
denis larocque 6-Sep-22 8:32am    
that work! thank!! i have modify a bit but is work . my only error is that not rename my file corectly.
my original file name is 10605P2B.02 and is rename to 10605P2B.02.wld i need to rename 10605P2B02.wld
Richard MacCutchan 6-Sep-22 8:38am    
It worked correctly for me, and changed all files from XXX.XX to XXX.wld.
denis larocque 6-Sep-22 8:43am    
yea that remove the .01 to .wld but i need to keep the 01 in the name of the file
ex: 123.01 to 12301.wlg
i have try to @file.wld but that give me 123.01.wld
Richard MacCutchan 6-Sep-22 8:51am    
Try this:
        forfiles /S /M  *.* /C "cmd /c rename @file @fname@ext.wld"
denis larocque 6-Sep-22 9:06am    
that perfect thankyou verry much you save my life :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900