Batch script to check if the file has one line and delete
Posted: 28 Nov 2016 21:35
Hi,
I am new to the forum, please help to suggest how can I achieve the below.
I am generating some .txt files in a particular directory from a datastage job (ETL tool), some times where there are no records the files are generated with header only. I tried deleting the files based on the file size but the problem is the files which are generated with header and the files which are generated with detail some time are of the same file size.
What I am trying to do is check in the directory(c:\tmp) if all the .txt files have only one line starting with CDRNO, if yes delete the files, but I am not sure how to achieve this.
Please suggest how can I write a batch script for this.
Regards,
Deepti
I am new to the forum, please help to suggest how can I achieve the below.
I am generating some .txt files in a particular directory from a datastage job (ETL tool), some times where there are no records the files are generated with header only. I tried deleting the files based on the file size but the problem is the files which are generated with header and the files which are generated with detail some time are of the same file size.
What I am trying to do is check in the directory(c:\tmp) if all the .txt files have only one line starting with CDRNO, if yes delete the files, but I am not sure how to achieve this.
Please suggest how can I write a batch script for this.
Regards,
Deepti