Solved Remove Leading zeros from a txt file

February 9, 2012 at 06:24:15
Specs: Windows XP
I have file that is a list of videos files that i have to move from on folder to another every day, but the list has leading zeros on the name.

Here what i have so far:

Result.txt - this is file that has my list in

File mover.bat

@echo off

for /F "tokens=*" %%a in (Result.txt) do (
if exist "c:\input\%%a.mpg" copy "c:\input\%%a.mpg" "c:\output\%%a.mpg"

but that when i run in to a issue my files don't have the leading zeros in there file name.

thank for any help.

See More: Remove Leading zeros from a txt file

Report •

February 9, 2012 at 07:48:25
✔ Best Answer
@echo off
setlocal EnableDelayedExpansion
for /F "tokens=*" %%a in (Result.txt) do (
  set row=%%a
  set num=
  for /L %%j in (0 1 10) do (
    if "!row:~%%j,1!" neq "0" if not defined num set num=!row:~%%j!
  if exist "C:\input\!num!.mpg" copy "C:\input\!num!.mpg" "C:\output" > nul

Please, try to post in a more correct English since what you wish looks quite confusing.

Report •

February 9, 2012 at 08:56:24
Thanks for you help,

Report •
Related Solutions

Ask Question