Hi, I manage to find a batch file for getting the last 10 lines for a file, but how to I get the last 10 lines for all the csv files in the folder?
Thanks.
Jeremy@echo off > newfile & setLocal enableDELAYedexpansion
set N=
for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
)
set /a X=!N!-10
set N=for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! gtr !X! echo %%a >> newfile
)
You CALL a subroutine for each csv.
=====================================
Life is too important to be taken seriously.M2
Thanks! I got it working
@echo off
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%A in ('dir /b *.csv') do (
set NAME=%%~nA
call :sub1 %%A
)
goto :eof:sub1
set N=
for /f "tokens=* delims= " %%L in (%*) do (
set /a N+=1
)
set /a X=!N!-10
set N=for /f "tokens=* delims= " %%L in (%*) do (
set /a N+=1
if !N! gtr !X! echo %%L >> !NAME!Done.csv
)
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |