Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

How to identify and delete empty files

jq2000
Beginner
888 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
888 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
888 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