/* * [Ensure.java] * * Summary: Ensure each of a list of files exists. * * Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2016-06-13 initial. */ package com.mindprod.ensure; import com.mindprod.common18.EIO; import com.mindprod.common18.ST; import com.mindprod.csv.CSVReader; import java.io.EOFException; import java.io.File; import java.io.FileReader; import java.io.IOException; import static java.lang.System.*; /** * Ensure each of a list of files exists. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2016-06-13 initial. * @since 2016-06-13 */ public class Ensure { // todo: add aption second coulumn date/time /** * when program first copyrighted */ private static final int FIRST_COPYRIGHT_YEAR = 2016; /** * embedded version string. */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String VERSION_STRING = "1.0"; /** * undisplayed copyright notice */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; @SuppressWarnings( { "UnusedDeclaration" } ) private static final String RELEASE_DATE = "2016-06-13"; private static final String USAGE = "Ensure [list.csv] list of filenames to check"; public static void main( final String[] args ) { if ( args.length != 1 ) { throw new IllegalArgumentException( USAGE ); } int missing = 0; try { final CSVReader r = new CSVReader( new FileReader( args[ 0 ] ) ); try { while ( true ) { final String filename = r.get(); r.skipToNextLine(); if ( ST.isEmpty( filename ) ) { continue; } final File file = new File( filename ); if ( !file.exists() ) { err.println( "Missing " + EIO.getCanOrAbsPath( file ) ); missing++; } } } catch ( EOFException e ) { r.close(); } } catch ( IOException e ) { err.println( "Problem reading file list " + e.getMessage() ); } err.println( missing + " missing files." ); } }