Windows Batch Files

Renaming a file to Current Time stamp

Below Script would create a file name fname.txt and the it would get renamed to the current time stamp

echo. > fname.txt

for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set NDate=%%a-%%b-%%c

for /f "tokens=1-2 delims=: " %%a in ('time /t') do set NTime=%%a.%%b

rename fname.txt Report_%NDate%_%NTime%.log

Tail for windows,

tail -5 <file_name> would grab last 5 lines of the file.

You could download the tail.exe from Windows Server 2003 Resource Kit Tools or from net.

Putting the data extract into new file

tail -5 <file_name> >> fname.txt

above would grab 5 lines from the file and put it into fname.txt

To copy your scanned file to folder with Timestamp

echo. > fname.txt

for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set NDate=%%a-%%b-%%c

for /f "tokens=1-2 delims=: " %%a in ('time /t') do set NTime=%%a.%%b

rename fname.txt Report_%NDate%_%NTime%.log

mkdir scan_%NDate%_%NTime%

move *.* scan_%NDate%_%NTime%

cd scan_%NDate%_%NTime%/

move /Y scan_%NDate%_%NTime%/fname.bat C:\batchtest\