Hello,
I m new here. I trying to create batch file. The purpose of this file it should retrieve specific data from the *.csv, example entire line that found percentage of 80 %. For example
Server Name Disk used Percentage
server A C 80 %
server B D 80 %
server C F 80 %
The entire row which containing of all 80 % should be export to text file.
My source of data would be *.csv or *.xls files.
Please advice me if this can done using batch file.
:: percent.bat 2020-11-12 17:59:01.36
@echo off > OUT.TXT & setLocal enableDELAYedeXpansioN
copy my.csv IN.TXT > nul
for /f “tokens=1-5 delims= ” %%a in (IN.TXT) do (
if %%d equ 80 echo.%%a %%b %%c %%d %%e
) >> OUT.TXT
goto :eof
the source file is saved as *,cvs
is not a filename.
Do this and post the list:
dir/b *.csv
Hello my apologise missed this..earlier…thanks for pointing…
Here is output
C:\capacity\percent>dir/b *.csv
my_csv.csv
when I run the percent.bat
C:\capacity\percent>my_percent.bat
The system cannot find the file IN.TXT.
The above is the error output then I getting on…
Thank you and appreciate your help….
:: percent.bat 2020-11-12 17:59:01.36
@echo off > OUT.TXT & setLocal enableDELAYedeXpansioN
copy my_csv.csv IN.TXT > nul
for /f “tokens=1-5 delims= ” %%a in (IN.TXT) do (
if %%d equ 80 echo.%%a %%b %%c %%d %%e
) >> OUT.TXT
goto :eof