| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
package org.jaudiotagger.test; |
| 23 | |
|
| 24 | |
import org.jaudiotagger.audio.AudioFileFilter; |
| 25 | |
import org.jaudiotagger.audio.AudioFileIO; |
| 26 | |
|
| 27 | |
import java.io.File; |
| 28 | |
import java.text.DateFormat; |
| 29 | |
import java.util.Date; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 0 | public class TestAudioTagger |
| 36 | |
{ |
| 37 | |
|
| 38 | |
public static void main(final String[] args) |
| 39 | |
{ |
| 40 | 0 | TestAudioTagger test = new TestAudioTagger(); |
| 41 | |
|
| 42 | 0 | if (args.length == 0) |
| 43 | |
{ |
| 44 | 0 | System.err.println("usage TestAudioTagger Dirname"); |
| 45 | 0 | System.err.println(" You must enter the root directory"); |
| 46 | 0 | System.exit(1); |
| 47 | |
} |
| 48 | 0 | else if (args.length > 1) |
| 49 | |
{ |
| 50 | 0 | System.err.println("usage TestAudioTagger Dirname"); |
| 51 | 0 | System.err.println(" Only one parameter accepted"); |
| 52 | 0 | System.exit(1); |
| 53 | |
} |
| 54 | 0 | File rootDir = new File(args[0]); |
| 55 | 0 | if (!rootDir.isDirectory()) |
| 56 | |
{ |
| 57 | 0 | System.err.println("usage TestAudioTagger Dirname"); |
| 58 | 0 | System.err.println(" Directory " + args[0] + " could not be found"); |
| 59 | 0 | System.exit(1); |
| 60 | |
} |
| 61 | 0 | Date start = new Date(); |
| 62 | 0 | System.out.println("Started to read from:" + rootDir.getPath() + " at " + DateFormat.getTimeInstance().format(start)); |
| 63 | 0 | test.scanSingleDir(rootDir); |
| 64 | 0 | Date finish = new Date(); |
| 65 | 0 | System.out.println("Started to read from:" + rootDir.getPath() + " at " + DateFormat.getTimeInstance().format(start)); |
| 66 | 0 | System.out.println("Finished to read from:" + rootDir.getPath() + DateFormat.getTimeInstance().format(finish)); |
| 67 | 0 | System.out.println("Attempted to read:" + count); |
| 68 | 0 | System.out.println("Successful to read:" + (count - failed)); |
| 69 | 0 | System.out.println("Failed to read:" + failed); |
| 70 | |
|
| 71 | 0 | } |
| 72 | |
|
| 73 | |
|
| 74 | 0 | private static int count = 0; |
| 75 | 0 | private static int failed = 0; |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
private void scanSingleDir(final File dir) |
| 82 | |
{ |
| 83 | |
|
| 84 | 0 | final File[] audioFiles = dir.listFiles(new AudioFileFilter(false)); |
| 85 | 0 | if (audioFiles.length > 0) |
| 86 | |
{ |
| 87 | 0 | for (File audioFile : audioFiles) |
| 88 | |
{ |
| 89 | 0 | count++; |
| 90 | |
try |
| 91 | |
{ |
| 92 | 0 | AudioFileIO.read(audioFile); |
| 93 | |
} |
| 94 | 0 | catch (Throwable t) |
| 95 | |
{ |
| 96 | 0 | System.err.println("Unable to read record:" + count + ":" + audioFile.getPath()); |
| 97 | 0 | failed++; |
| 98 | 0 | t.printStackTrace(); |
| 99 | 0 | } |
| 100 | |
} |
| 101 | |
} |
| 102 | |
|
| 103 | 0 | final File[] audioFileDirs = dir.listFiles(new DirFilter()); |
| 104 | 0 | if (audioFileDirs.length > 0) |
| 105 | |
{ |
| 106 | 0 | for (File audioFileDir : audioFileDirs) |
| 107 | |
{ |
| 108 | 0 | scanSingleDir(audioFileDir); |
| 109 | |
} |
| 110 | |
} |
| 111 | 0 | } |
| 112 | |
|
| 113 | |
|
| 114 | 0 | public final class DirFilter implements java.io.FileFilter |
| 115 | |
{ |
| 116 | |
public DirFilter() |
| 117 | 0 | { |
| 118 | |
|
| 119 | 0 | } |
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
public final boolean accept(final java.io.File file) |
| 131 | |
{ |
| 132 | 0 | return file.isDirectory(); |
| 133 | |
} |
| 134 | |
|
| 135 | |
public static final String IDENT = "$Id: TestAudioTagger.java 832 2009-11-12 13:25:38Z paultaylor $"; |
| 136 | |
} |
| 137 | |
} |