1.

Solve : Help needed on renaming filenames with .bat?

Answer»

Hello forum users,

First of all, my English isn't perfect; sorry for that. I like to do some editing on the PC-games I play. Now I kind of have an issue which needs your help.

I have a map with files named like this: head_1234_0.rx3 There a around 1500 of them, the numbers are all different and linked to a database. These are original files.
I also have one head_x_bump.rx3 were the x should be CORRESPONDING to the 1234. I need all 1500 files to have a corresponding head_x_bump file. I can do this manualy, but that's too much work. That's why I created a bat file with the following code:Code: [Select]echo Enter number
set /p number=
COPY head_x_bump.rx3 head_%number%_bump.rx3
It works, but it's still a lot of work. I thougt that maybe it's possible to create a bat file wich "reads" the file names of the orriginal files.
I have no idea how to do this.

So is it possible to link the "1234" in the orginial filename to a copied en renamed head_x_bump file?


so basicly you have 1 copy of a file named "head_x_bump.rx3" and you need to make a bunch of copies of it replacing x with a number?

Code: [Select]@echo off
set end=####

for /l %%A in (1,1,%end%) do copy "head_x_bump.rx3" "head_%%A_0.rx3" && echo Copied number %%A.

echo . . . Done
pause>nul

Or you have a bunch of "head_####_bump.rx3 and need a corresponding head_####_0.rx3 file for each,

Code: [Select]@echo off
end=####

for /l %%A in (1,1,%end%) do copy "head_%%A_bump.rx3" "head_%%A_0.rx3" && echo Copied number %%A.
echo . . . Done
pause>nul



Where end equals the total number of files (assuming there are no skips in numbers).Lemonilla, you want the 2nd line of your 2nd script to be

SET end=####Quote from: Lemonilla on December 15, 2013, 11:43:30 AM

so basicly you have 1 copy of a file named "head_x_bump.rx3" and you need to make a bunch of copies of it replacing x with a number?

Exactly!I added a picture to as example.



I have around 1500 head_x_0.rx3 files that need a corresponding head_x_bump.rx3 (of which
I have one version that I need to copy with corresponding numbers). For exaple the head_260084_bump.rx3 is what I need to create. Problem is -as you can see- the numbers do skip.

So basicly I'm LOOKING to make a copy of the head_x_bump and get the numbers from the head_260074_0.rx3 in the name of bump file at the position of the x

This creates the extra files, using the numbers from the existing files.

Code: [Select]@echo off
for /f "tokens=2 delims=_" %%a in ('dir head_*_0.rx3 /b /a-d ') do type nul >"head_%%a_bump.rx3"Wauw, thnx!! It looks like it creates the files, but doesn't copy the original head_x_bump file. almost there My mistake - but it's a simple change.

Code: [Select]@echo off
for /f "tokens=2 delims=_" %%a in ('dir head_*_0.rx3 /b /a-d ') do copy "head_x_bump.rx3" "head_%%a_bump.rx3" >nulI tried the same, but now I see I added an unnecessary >

Thnx a lot, it works!


Discussion

No Comment Found