diff --git a/Toolbox Migration/src/com/bayer/edam/excelimport/CropAssetCopyTool.java b/Toolbox Migration/src/com/bayer/edam/excelimport/CropAssetCopyTool.java index 8077591..5c5c9ee 100644 --- a/Toolbox Migration/src/com/bayer/edam/excelimport/CropAssetCopyTool.java +++ b/Toolbox Migration/src/com/bayer/edam/excelimport/CropAssetCopyTool.java @@ -41,8 +41,6 @@ public class CropAssetCopyTool { private static File targetDir = new File("D:\\UploadAssets"); private static String videoTargetPath = "D:\\UploadVideos"; - private static File videoTargetDir = new File(videoTargetPath); - private CsvParserSettings parserSettings = new CsvParserSettings(); @@ -67,8 +65,6 @@ public class CropAssetCopyTool { int noContent = 0; int wrongSize = 0; int video = 0; - int videosExtracted = 0; - int videosZipped = 0; int zipCorrupt = 0; for (String[] line : inputRows) { @@ -109,35 +105,33 @@ public class CropAssetCopyTool { try { zipFile = new ZipFile(videoFile.getAbsolutePath()); + @SuppressWarnings("unchecked") List fileList = (List) zipFile.getFileHeaders(); + FileHeader header = null; + if (fileList.size() == 1) { - log.debug("Extracting " + videoFile.getAbsolutePath()); - - if (!dryRun) { - zipFile.extractAll(videoTargetPath); - - FileHeader header = (FileHeader) fileList.get(0); - File srcFile = new File(videoTargetPath + "\\" + header.getFileName()); - File destFile = new File(videoTargetPath + "\\" + targetName); - log.info("AssetID " + assetId + ": Moving " + srcFile.getAbsolutePath() + " to " + destFile.getAbsolutePath()); - - FileUtils.moveFile(srcFile, destFile); - } - - videosExtracted++; + header = fileList.get(0); } else { - for (FileHeader header : fileList) { - if (header.getFileName().indexOf('/') < 0) { - if (!dryRun) - zipFile.extractFile(header, videoTargetPath); - videosExtracted++; + for (FileHeader hdr : fileList) { + if (hdr.getFileName().indexOf('/') < 0) { + header = hdr; break; } } } + log.debug("Extracting " + videoFile.getAbsolutePath()); + if (!dryRun) { + zipFile.extractFile(header, videoTargetPath); + File srcFile = new File(videoTargetPath + "\\" + header.getFileName()); + File destFile = new File(videoTargetPath + "\\" + targetName); + log.info("Line " + lineNo + ", AssetID " + assetId + ": Moving " + srcFile.getAbsolutePath() + " to " + destFile.getAbsolutePath()); + + FileUtils.moveFile(srcFile, destFile); + } + video++; } catch (ZipException e) { @@ -169,7 +163,7 @@ public class CropAssetCopyTool { targetFile = new File(targetDir + "\\" + newName); } - log.info("AssetID " + assetId + ": Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'"); + log.info("Line " + lineNo + ", AssetID " + assetId + ": Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'"); line[1] = targetFile.getName(); } @@ -204,8 +198,6 @@ public class CropAssetCopyTool { log.info("Wrong size: " + wrongSize); log.info("Videos: " + video); - log.info(" Extracted: " + videosExtracted); - log.info(" Zipped: " + videosZipped); log.info(" Corrupt: " + zipCorrupt); }