Batch file rename

March 31, 2010 at 03:25:53
Specs: Windows XP
Hello,
I'm facing a small problem with windows rename (ren) command. I have lot's of files that looks something
like this
1234_1234567_87654321.jpg
Now I need to cut two first parts away.
So the file should look like 87654321.jpg
...but it seems that there is no way to "cut" filename from beginning with easy command or is there?

See More: Batch file rename

Report •


#1
March 31, 2010 at 05:41:53
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d *.jpg') do (
for /f "tokens=3 delims=_" %%i in ("%%~Na") do (
ren %%a %%i%%~Xa
)
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
April 1, 2010 at 01:36:47
I Bow and Thank you!
Works just like dream!

Previously I found this, but for some reason it did not work wery well.

@echo on & setlocal EnableDelayedExpansion
for %%j in (*.jpg) do (set file=%%~nxj rename %%j !file:~13!)
:: End_Of_Batch



Report •

#3
April 1, 2010 at 01:50:05
At first glance, that one knocks off a fixed number of chars. Not what you need.


=====================================
Helping others achieve escape felicity

M2


Report •
Related Solutions


Ask Question