bat programming

Insert delay

echo off

::3 sec delay

TIMEOUT /T 3

::6 sec delay

PING localhost -n 6 >NUL


Append 0xFF to existing file

echo off

if %1'==' goto :usage

if %2'==' goto :usage

if not exist %1 echo %1 was not found && goto :eof

:loop

(set/p z=ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ)>>%1

if %~z1 GTR %2 goto done

goto loop

:done

echo %~z1

goto :eof

:usage

echo. Usage:-

echo. addff filename size

echo.     where filename=file to be append, size=final file size

echo.     e.g.

echo.         addff file.bin 1048576


Scan files and rename extension

@echo off

setlocal ENABLEDELAYEDEXPANSION

FOR /r C:\Temp %%f IN (*.*) DO (

  set fn=%%f

  set nfn=!fn:~0,-1!

  move "%%f" "!nfn!"

)


Scan files and rename extension (add 1)

@echo off

setlocal ENABLEDELAYEDEXPANSION

FOR /r C:\Temp %%f IN (*.*) DO (

  set fn=%%f

  echo !fn!

  move "%%f" "%%f"1

)