Skip to content

Instantly share code, notes, and snippets.

@joelbyler
Created November 25, 2012 23:07
Show Gist options
  • Save joelbyler/4145806 to your computer and use it in GitHub Desktop.
Save joelbyler/4145806 to your computer and use it in GitHub Desktop.
Remove leading zeroes from all files in current directory
@echo off
SetLocal EnableDelayedExpansion
for %%a in (*) do (
call :DeleteLeadingZeros %%a
if not exist !NewName! (ren %%a !NewName!)
)
exit /b
:DeleteLeadingZeros %1
for /f "tokens=* delims=0" %%a in ("%1") do (set NewName=%%a)
exit /b
REM credit goes to the site below for the original work
REM http://www.computing.net/answers/programming/bat-to-cut-leading-zeros-from-file-names/23653.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment