Reputation: 133
I have a problem in a folder which contains sql files. I want to check that the last line of each file contain only one slash '/' (without any spaces after that) and if there is issue to write in the output that an error is raised ie 1.sql error 5.sql error
Is there any easy way to do it with a batch file ?
Thank you in advance
Upvotes: 1
Views: 541
Reputation: 9545
This should do it :
@echo off&cls
setlocal enabledelayedexpansion
for %%a in (*.sql) do (echo Treating =^> %%a
for /f "delims=" %%b in ('type "%%a"') do (
set "$Line=%%b"
)
echo - Last Char =^> [!$Line:~-1!]
if not "!$Line:~-1!"=="/" (
echo - Result =^> error %%~nxa
) else (
echo - Result =^> OK %%~nxa
)
echo.^****
)
Upvotes: 2