Solved Delete the File and Capture the Status

November 16, 2017 at 06:04:04
Specs: Windows 7

I am new to batch scripting, trying to do the below scenario in batch scripting. I tried initially to do it in DataStage but I am not getting the expected results.

I have an input file which has the below data. I have to delete the file and capture the status if the file is deleted or not in a new file.

Input File
Identifier, FileDetails

OutPut File
Identifier, FileStatus
655, File Not Found
656, Path does not exist

can any one give me a idea on how to do this.

Thank you.

See More: Delete the File and Capture the Status

Report •

November 16, 2017 at 07:44:37
✔ Best Answer
Here you go, just checks if the files are there or not, please test test.bat & report back to me

also dont forget to change output.txt&input.txt to you specific filenames

@echo off
set "outputfile=output.txt"
set "inputfile=input.txt"
echo Indentifier, FileDetails>%outputfile%
for /f "tokens=1,2 delims=," %%a in (%inputfile%) do (
if exist "%%b" (
echo %%a, File exists>>%outputfile%
) else (
echo %%a, File not found>>%outputfile%

i5-6600K@4.7GHz/4.5GHz cache@1.355v | 2x4GB Crucial-DDR4-2133@ 14-14-14-29 1T 2800MHz@1.345v | ASUS Z170-K | Samsung 250GB SSD 850 EVO | MSI Radeon RX 570 ARMOR 4GB@1330cc&1895mem | Corsair CX450 450W

Report •
Related Solutions

Ask Question