core
Class DuplicateFiles

java.lang.Object
  extended by core.DuplicateFiles

public class DuplicateFiles
extends java.lang.Object

This class is used to identify Duplicate files that iTunes creates when iTunes is set to keep the music folder organized. As of version 9 iTunes contains this setting in Edit > Preferences > Advanced > Keep iTunes Media folder organized. Duplicates are found by inspecting file names for iteration counts. If no duplicates are in a folder than a track might be named "01 Track.mp3". If there are duplicates of Track that iTunes created they will be named "01 Track i.mp3" where i is the number of that duplicate.


Constructor Summary
DuplicateFiles()
          Creates an empty DuplicateFiles object.
 
Method Summary
 java.util.ArrayList<java.io.File> getDuplicatesInFolder(java.io.File[] filesInFolder)
          Returns an array list of the files that are found to be duplicates within the given folder.
 boolean isDuplicate(java.io.File file, java.io.File[] directoryFiles)
          Determines whether a file is a duplicate given the other files in that same directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DuplicateFiles

public DuplicateFiles()
Creates an empty DuplicateFiles object.

Method Detail

isDuplicate

public boolean isDuplicate(java.io.File file,
                           java.io.File[] directoryFiles)
Determines whether a file is a duplicate given the other files in that same directory. A file is a duplicate if it both has an iteration number at the end of the file name a file without the iteration count exists in the same directory. For example, 01 Track.mp3 and 01 Track 1.mp3. 01 Track 1.mp3 is a duplicate. However, a file is not a duplicate if 01 Track 1.mp3 exists in the directory but 01 Track.mp3 does not.

Parameters:
file - the file to test whether it is a duplicate
directoryFiles - all of the file in a given directory including the test file
Returns:
boolean value as to whether or not the file is a duplicate

getDuplicatesInFolder

public java.util.ArrayList<java.io.File> getDuplicatesInFolder(java.io.File[] filesInFolder)
                                                        throws java.lang.NullPointerException
Returns an array list of the files that are found to be duplicates within the given folder.

Parameters:
filesInFolder - the array of files in a directory to check for duplicates
Returns:
the array list of files that are duplicates from the given array
Throws:
java.lang.NullPointerException - thrown if the fileInFolder array is null