Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29280 Discussions

How to identify and delete empty files

jq2000
Beginner
878 Views
A Fortran application read industrial parameters from a database, stores classified data into a set of newly generated files. If there is no a specific type of parameters, the correspondent output file will be empty. I hope to delete those empty files in the end of execution. Is there any easy way to identify files with size of 0 KB and delete them?
0 Kudos
2 Replies
TimP
Honored Contributor III
878 Views
Ease may depend on what additional tools you are willing to use. Attempting to purge 0 size files purely in Fortran is likely to be clumsy, particularly if you haven't kept a list of the file names. Best choices might be between invoking a script, which could be run from CALL SYSTEM(), or Windows API calls.
0 Kudos
Steven_L_Intel1
Employee
878 Views
You could use GETFILEINFOQQ with a wildcard file specification to get the info for each file created, and look at the LENGTH value to find the zero-length files. You can then call DELETEFILEQQ for the file.

Steve
0 Kudos
Reply