|
Answer» Hi.
I need to rename files in my "dir1" directory. The filename for example: 123_some_thing1_abracadabra.txt
I need to rename it in: 123_some_thing1.txt
Any sugestions?
Thanks in advance.
Please do not post the same question more than once. It labels you a double poster or (gasp) a triple poster.
Provided all the file names have the same naming pattern (3 underscores, 1 dot) and the new names all have a pattern (2 underscores and 1 dot), you simply parse the filenames and then rebuild them like Humpty Dumpty:
Code: [Select] @ECHO off for /f "tokens=1-5 delims=_." %%a in ('dir1 *.txt /b') do ( ren %%a_%%b_%%c_%%d.%%e %%a_%%b_%%c.%%e )
Hope this helps. Sidewinder can you help me with this tokens and delims.
I have tried many times but somehow could get to exactly how it works. You can always just right CLICK the file NAME and rename it to whatever you want.Triple posting gets the long walk to the Sin Bin. You need to discuss this with Fed to avoid prosecution.
Hi.
Sotty for triple post, but it's not my fault. Brouser's i gess.
I've come up with this solution? It realy works: DIR /B > f.txt for /F "eol=; tokens=1,2,3,4* delims=_" %%A in ('find ".VOX" f.txt') do ( IF %%E GTR 0 rename %%A_%%B_%%C_%%D_%%E %%A_%%B_%%C_%%D.vox ) del f.txt
Thanks for example.
|