|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectBookNames
public class BookNames
Used to get ISBNs for books.
| Field Summary | |
|---|---|
static java.lang.String |
cmd1
To run a cmd prompt in java on windows rt.excec(new String[]{"", "", ""...}) input is "cmd", "/c"... |
static java.lang.String |
cmd2
To run a cmd prompt in java on windows rt.excec(new String[]{"", "", ""...}) input is "cmd", "/c"... |
static java.lang.String |
fISBN
The text following the ISBN number but preceding the extension in the renamed filenames. |
private static boolean |
going
Used as a flag in isbnDriver(). |
static long |
maxDvdSize
The size in bytes of the DVD used. |
static int |
numberOfISBNsPerBook
The maximum number of ISBNs to look for/retain per each book. |
static int |
numberOfLines
The maximum number of lines in a text file that is read into an array when reading the file. |
static int |
numberOfPreviousLines
The default number of lines that is printed before and after each ISBN found in the book. |
static java.lang.String |
pISBN
The text preceding the ISBN number in the renamed filenames. |
| Constructor Summary | |
|---|---|
BookNames()
|
|
| Method Summary | |
|---|---|
private static int |
badISBN(java.lang.String[] lines,
java.lang.String[][] list,
java.lang.String tempPath)
If no ISBNs were found in the book, this more desperate method is used to get anything that is remotely possibly an ISBN. |
private static java.lang.String[] |
checkDupISBN(java.lang.String[][] list,
int k,
java.lang.String nome)
This method decides if there are any duplicates in any of many ways. |
private static boolean |
compareETitle(java.lang.String a,
java.lang.String b)
Compares two book titles for equality. |
private static boolean |
comparesToTitle(java.lang.String title,
java.lang.String amazonTitle)
Attempts to compare the title downloaded from amazon or isbndb to the filename of the current book. |
static void |
delDuplicates(java.lang.String filesPath,
java.lang.String moveToPath)
Searches through the folder for duplicate files and moves them to another folder. |
static void |
deleteDvdFiles(java.lang.String listFile,
java.lang.String txtFilesPath,
java.lang.String tag,
java.lang.String movedFilesPath)
This continues from from the above method prepereDVD(). |
static void |
extractCHM(java.lang.String chmOriginPath,
java.lang.String txtResultPath)
Generates a DOS cmd command for the program minetext (http://text-mining-tool.com/) to extract all the text from each chm file found in the chmOriginPath directory and save it as a text file in txtResultPath. |
static java.lang.String |
extractISBN(java.lang.String line)
Searches for and extracts an ISBN number from line. |
static void |
genPDFTKcat(java.lang.String originalPath,
java.lang.String pdftkOutputPath,
java.lang.String isbnOutputPath)
Generates the DOS cmd pdftk command to catenate the first 20 pages of a pdf file for all files in the folder. |
static java.lang.String |
getISBN(java.lang.String filename,
java.lang.String nome,
int t,
java.lang.String tempPath)
Searches through a text file and returns the correct ISBN number for this book. |
static boolean |
isbn1013check(java.lang.String isbn1,
java.lang.String isbn2)
Compares two ISBNs to see if one is the ISBN-13 and the other is ISBN-10 but both represent the same book. |
static void |
isbnDriver(java.lang.String txtFilesPath,
java.lang.String ext,
java.lang.String pdfFilesPathOrigin,
java.lang.String pdfFilesPathtarget,
java.lang.String smallPDFFilePath,
java.lang.String backupPath,
java.lang.String txtResultPath)
This is the main program that gets ISBNs and renames the books to their ISBNs. |
static void |
main(java.lang.String[] args)
|
static java.io.File |
matchesString(java.io.File dir,
java.lang.String regex)
Tries to match regex to the file names of all files in this directory and its sub-directories. |
static java.lang.String[] |
moveFile(java.lang.String pathOrigin,
java.lang.String pathTarget,
java.lang.String[] files)
Generates a move command Windows DOS cmd to move a file or directory to a new location. |
static void |
moveFileWithISBNTitle(java.lang.String dirPath,
java.lang.String resultPath)
Given directory dirPath it looks through all the folders and files in dirPath for a file with a legitimate ISBN in the filename. |
static void |
moveSingleFiles(java.lang.String dirPath,
java.lang.String resultPath,
int fileOrDir)
It looks through a directory for folders containing only one file or for folders without any files. |
static void |
moveWhatever(java.lang.String dirPath,
java.lang.String resultPath,
java.lang.String regex)
Given a directory dirPath it will match each of its files and files in its sub-dirs to string regex. |
static java.lang.String |
pdftkCat(java.lang.String[] originalPDFs,
java.lang.String outputFile,
java.lang.String tempPath)
Generates the DOS cmd pdftk (http://www.accesspdf.com/pdftk/) command to catenate the first 20 pages of a list of pdf files into one file. |
static void |
pdftkWhatever(java.lang.String dirPath,
java.lang.String resultPath,
java.lang.String regex)
Given a directory dirPath it will match each of its files and files in its sub-dirs to string regex. |
static void |
prepereDVD(java.lang.String listFile,
java.lang.String opfPath,
java.lang.String txtFilesPath,
java.lang.String tag)
This is used to backup books in calibre to a DVD. |
private static void |
printISBNwithLines(java.lang.String[][] isbns,
java.lang.String[] lines,
int numberOfLines,
int k)
Used to print the ISBNs found in the book so we can select the correct ISBN. |
static java.lang.String[] |
removeExt(java.lang.String[] s)
Removes extension of each file name in the array. |
static java.lang.String[] |
renameFile(java.lang.String path,
java.lang.String[] original,
java.lang.String[] renamed)
Generates a rename command for Windows DOS cmd. |
private static int |
selectISBN(java.lang.String nome,
java.lang.String[][] list,
int k)
Another method to decide which ISBN to select from the list. |
static java.lang.String |
titleIsISBN(java.io.File dir)
Looks for a ISBN number in the name of the file or directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int numberOfLines
public static int numberOfPreviousLines
public static int numberOfISBNsPerBook
private static boolean going
public static final long maxDvdSize
public static final java.lang.String pISBN
public static final java.lang.String fISBN
public static final java.lang.String cmd1
public static final java.lang.String cmd2
| Constructor Detail |
|---|
public BookNames()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
public static java.lang.String[] removeExt(java.lang.String[] s)
s - An array of filenames.
public static java.lang.String[] renameFile(java.lang.String path,
java.lang.String[] original,
java.lang.String[] renamed)
The - full Path of the directory where the original files are present.original - The list of filenames of the original files. Only the names - excluding the path.renamed - The new filename for the original files. Only the names - excluding the path. renamed[i] corresponds to original[i].
public static java.lang.String[] moveFile(java.lang.String pathOrigin,
java.lang.String pathTarget,
java.lang.String[] files)
pathOrigin - The full Path of the directory where the files are present.pathTarget - The full Path of the directory where the files will be moved to.files - The list of filenames to be moved. Only the names - excluding the path.
public static java.lang.String pdftkCat(java.lang.String[] originalPDFs,
java.lang.String outputFile,
java.lang.String tempPath)
originalPDFs - a list of filenames including full path i.e. C:\myName1.pdf which will be extracted and catnated into one pdf fileoutputFile - The full path and name of the file that the generated pdf will be saved as i.e. C:\newFile.pdf.tempPath - A full path to a directory where some temp files will be saved.
public static void genPDFTKcat(java.lang.String originalPath,
java.lang.String pdftkOutputPath,
java.lang.String isbnOutputPath)
originalPath - The directory/full path where the pdf files to be extracted are.pdftkOutputPath - the full path where the files to be extracted by pdftk will be saved.isbnOutputPath - The full path where the files with ISBNs in their names will be moved to when renamed.
It saves 3 text files. One the generated pdftk command. Two, a list of files that had ISBNs listedas the old name followed
by the new name i.e. File3333333333333.pdf :-->: t;3333333333333.pdf for backup. Third, a list of files with ISBNs where rename failed and
pdftk wasn't generated for that file.
public static void delDuplicates(java.lang.String filesPath,
java.lang.String moveToPath)
filesPath - The full path of the directory where it should search for duplicates.moveToPath - The full path of the directory where the duplicates will be moved.
It also saves a text file listing all the duplicates that failed to be deleted.
public static void isbnDriver(java.lang.String txtFilesPath,
java.lang.String ext,
java.lang.String pdfFilesPathOrigin,
java.lang.String pdfFilesPathtarget,
java.lang.String smallPDFFilePath,
java.lang.String backupPath,
java.lang.String txtResultPath)
txtFilesPath - The full path of the directory where the extracted text files were saved to and currently are in.ext - The extension of the original book. i.e. pdf, chm, djv and NOT .pdf, .chm etc.pdfFilesPathOrigin - The full path of the directory where the original books are.pdfFilesPathtarget - The full path of the directory where the original books will be moved to after they are renamed to their ISBNssmallPDFFilePath - The full path of the directory where the smaller sized extracted pdfs are in. If there are no such files or the book isn't PDF set to nullbackupPath - The full path of the directory where the smaller sized PDFs and extracted text files will be moved to for backup purposes after the ISBN has been extracted.txtResultPath - The full path of the directory where the text files for failed and backup will be saved to.
public static java.lang.String getISBN(java.lang.String filename,
java.lang.String nome,
int t,
java.lang.String tempPath)
filename - The full path and filename of the txt file that potentially contains an ISBN number.nome - The name of the book that is searched for an ISBN.t - The number of the book in the list of books, used for printing purposestempPath - A directory where some temporary files will be saved to.
private static java.lang.String[] checkDupISBN(java.lang.String[][] list,
int k,
java.lang.String nome)
list - The matrix that contains the ISBN numbers and associated info of a single book.k - roughly the number of ISBNs in list.nome - The file name of the book.
private static int selectISBN(java.lang.String nome,
java.lang.String[][] list,
int k)
nome - The file name of the book.list - The matrix that contains the ISBN numbers and associated info of a single book.k - roughly the number of ISBNs in list.
public static boolean isbn1013check(java.lang.String isbn1,
java.lang.String isbn2)
isbn1 - One ISBNisbn2 - Another ISBN
private static boolean compareETitle(java.lang.String a,
java.lang.String b)
a - title ab - title b
private static boolean comparesToTitle(java.lang.String title,
java.lang.String amazonTitle)
title - book filenameamazonTitle - Title downloaded from amazon
private static void printISBNwithLines(java.lang.String[][] isbns,
java.lang.String[] lines,
int numberOfLines,
int k)
isbns - The matrix representing all the ISBNs found in the book and their associated info.lines - The whole text file of the current book.numberOfLines - Selects the number of lines to print before and after the ISBN number.k - is output from the function calling it, it's roughly the number of ISBNs found in the book.public static java.lang.String extractISBN(java.lang.String line)
line - The string potentially containing an ISBN number.
private static int badISBN(java.lang.String[] lines,
java.lang.String[][] list,
java.lang.String tempPath)
lines - The text of the book.list - The matrix representing all the ISBNs found in the book and their associated info.tempPath - A directory where some temporary files will be saved to.
public static void extractCHM(java.lang.String chmOriginPath,
java.lang.String txtResultPath)
chmOriginPath - The directory where the chm files are present.txtResultPath - The directory where the extracted text files should be saved to.
public static void prepereDVD(java.lang.String listFile,
java.lang.String opfPath,
java.lang.String txtFilesPath,
java.lang.String tag)
listFile - This is a list file of all the FILES in calibre's library. It should not contain metadata.db and the files listed should have the full path followed by the filename. "PrintFolder" can generates such a list. It should also not list empty directories ONLY FILES.opfPath - a temporary directory where opf files are saved for the duration of the session.txtFilesPath - a temporary directory where text files are saved for the duration of the session.tag - The tag used in calibre to indicate that this files is on DVD x. For example, DVD_Books_5.
May not be completely windows independent. Use at your own risk. Though it worked for me.
public static void deleteDvdFiles(java.lang.String listFile,
java.lang.String txtFilesPath,
java.lang.String tag,
java.lang.String movedFilesPath)
listFile - The same listFile as above.txtFilesPath - A temporary directory where text files are saved for the duration of the session.tag - The tag given for the book in the above methodmovedFilesPath - The target path where the books to be deleted are moved to.
May not be completely windows independent. Use at your own risk. Though it worked for me.
public static void moveWhatever(java.lang.String dirPath,
java.lang.String resultPath,
java.lang.String regex)
dirPath - The directory where it'll look for matches.resultPath - The directory where matching files/directories will be moved.regex - The string regex with what to match the files.
public static void pdftkWhatever(java.lang.String dirPath,
java.lang.String resultPath,
java.lang.String regex)
dirPath - he directory where it'll look for matches.resultPath - The directory where pdftk will save the extracted files.regex - The string regex with what to match the files.
public static void moveFileWithISBNTitle(java.lang.String dirPath,
java.lang.String resultPath)
dirPath - The full path to the directory to search for files or folders with ISBNs in their names.resultPath - The path where files or directories with ISBNs in their names should be moved to.
public static java.io.File matchesString(java.io.File dir,
java.lang.String regex)
dir - The directory to search for a matching filecontains - The regex used to try to match the filename.
public static void moveSingleFiles(java.lang.String dirPath,
java.lang.String resultPath,
int fileOrDir)
dirPath - The containing directory which will have its folders and files searched through.resultPath - The full path where the files or directory should be moved to.fileOrDir - 0 to move all the empty folders, even if they have empty sub-folders. 1 to move the files that are the only files in their directory i.e. folder containing only one filepublic static java.lang.String titleIsISBN(java.io.File dir)
dir - The directory or file with a potential ISBN number in their name.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||