| 1 | |
package org.jaudiotagger.test; |
| 2 | |
|
| 3 | |
import org.jaudiotagger.audio.mp3.MP3File; |
| 4 | |
|
| 5 | |
import java.io.File; |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | 0 | public class ExtractID3TagFromFile |
| 12 | |
{ |
| 13 | |
|
| 14 | |
public static void main(final String[] args) |
| 15 | |
{ |
| 16 | 0 | ExtractID3TagFromFile test = new ExtractID3TagFromFile(); |
| 17 | |
|
| 18 | 0 | if (args.length != 2) |
| 19 | |
{ |
| 20 | 0 | System.err.println("usage ExtractID3TagFromFile Filename FilenameOut"); |
| 21 | 0 | System.err.println(" You must enter the file to extract the tag from and where to extract to"); |
| 22 | 0 | System.exit(1); |
| 23 | |
} |
| 24 | |
|
| 25 | 0 | File file = new File(args[0]); |
| 26 | 0 | File outFile = new File(args[1]); |
| 27 | 0 | if (!file.isFile()) |
| 28 | |
{ |
| 29 | 0 | System.err.println("usage ExtractID3TagFromFile Filename FilenameOut"); |
| 30 | 0 | System.err.println(" File " + args[0] + " could not be found"); |
| 31 | 0 | System.exit(1); |
| 32 | |
} |
| 33 | |
|
| 34 | |
try |
| 35 | |
{ |
| 36 | 0 | final MP3File tmpMP3 = new MP3File(file); |
| 37 | 0 | tmpMP3.extractID3v2TagDataIntoFile(outFile); |
| 38 | |
} |
| 39 | 0 | catch (Exception e) |
| 40 | |
{ |
| 41 | 0 | System.err.println("Unable to extract tag"); |
| 42 | 0 | System.exit(1); |
| 43 | 0 | } |
| 44 | 0 | } |
| 45 | |
|
| 46 | 0 | final class MP3FileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter |
| 47 | |
{ |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
private final boolean allowDirectories; |
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
public MP3FileFilter() |
| 59 | |
{ |
| 60 | 0 | this(false); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
private MP3FileFilter(final boolean allowDirectories) |
| 71 | 0 | { |
| 72 | 0 | this.allowDirectories = allowDirectories; |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
public final boolean accept(final File file) |
| 84 | |
{ |
| 85 | 0 | return (((file.getName()).toLowerCase().endsWith(".mp3")) || (file.isDirectory() && (this.allowDirectories == true))); |
| 86 | |
} |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
public final String getDescription() |
| 94 | |
{ |
| 95 | 0 | return new String(".mp3 Files"); |
| 96 | |
} |
| 97 | |
} |
| 98 | |
|
| 99 | |
public static final String IDENT = "$Id: ExtractID3TagFromFile.java,v 1.5 2008/07/21 10:46:30 paultaylor Exp $"; |
| 100 | |
|
| 101 | |
} |