Skip to content
This repository was archived by the owner on Nov 29, 2019. It is now read-only.

Commit f695b2a

Browse files
committed
Main.java: Output files are named "basename_xmp.pdf". Output dir
works.
1 parent 9fd1899 commit f695b2a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ bin
22
output
33
*.swp
44
*~
5+
pdfmark.jar

src/org/crossref/pdfmark/Main.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,22 @@ public Main(String[] args) {
144144
* is already in each PDF. */
145145

146146
for (String pdfFilePath : parser.getRemainingArgs()) {
147-
String outputPath = pdfFilePath + ".out";
147+
String outputPath = getOutFileName(pdfFilePath);
148+
149+
/* Grab the leaf. */
150+
if (outputPath.contains(File.separator)) {
151+
String[] split = outputPath.split(File.separator);
152+
outputPath = split[split.length - 1];
153+
}
148154

149155
if (!outputDir.isEmpty()) {
150156
outputPath = outputDir + File.separator + outputPath;
157+
} else {
158+
/* Output to the working directory. */
151159
}
152160

153161
File pdfFile = new File(pdfFilePath);
154-
File outputFile = new File(pdfFilePath + ".out");
162+
File outputFile = new File(outputPath);
155163

156164
byte[] resolvedXmpData = null;
157165

@@ -276,6 +284,15 @@ public void onFailure(String doi, int code, String msg) {
276284
return builder.getXmpData();
277285
}
278286

287+
private static String getOutFileName(String pdfFileName) {
288+
if (pdfFileName.endsWith(".pdf")) {
289+
return pdfFileName.substring(0, pdfFileName.length() - 4)
290+
+ "_xmp.pdf";
291+
} else {
292+
return pdfFileName + "_xmp.pdf";
293+
}
294+
}
295+
279296
private void exitWithError(int code, String error) {
280297
shutDown();
281298
System.err.println();

0 commit comments

Comments
 (0)