bat to cut leading zeros from file names

December 21, 2010 at 22:12:43
Specs: Windows XP
Hi!
I need a bat to cut leading zeroes from file names, for example
001.jpg > 1.jpg
099.jpg > 99.jpg
Thanks
DearWebby

See More: bat to cut leading zeros from file names

Report •


#1
December 22, 2010 at 13:48:33
Hi DearWebby

@echo off
SetLocal EnableDelayedExpansion
for %%a in (*.jpg) do (
call :DelLeadZeros %%a
if not exist !NewName! (ren %%a !NewName!)
)
exit /b


:DelLeadZeros %1
for /f "tokens=* delims=0" %%a in ("%1") do (set NewName=%%a)
exit /b


Report •

#2
December 22, 2010 at 14:20:02
Thanks dtech10!
That should work nicely!

Report •

Related Solutions


Ask Question