CropAssetCopyTool

This commit is contained in:
gexce
2017-08-17 16:40:34 +02:00
parent 1fb31470f3
commit a7a98c0f51
@@ -155,19 +155,19 @@ public class CropAssetCopyTool {
if (targetFile.exists()) {
while (targetFile.exists()) {
String oldName = FilenameUtils.removeExtension(targetFile.getName());
String newName = oldName + "--002." + FilenameUtils.getExtension(oldName);
String extension = FilenameUtils.getExtension(targetFile.getName());
String newName = oldName + "--002." + extension;
if (oldName.length() > 5 && oldName.charAt(oldName.length() - 4) == '-'
&& oldName.charAt(oldName.length() - 3) == '-'
&& StringUtils.isNumeric(oldName.substring(oldName.length() - 3))) {
int num = Integer.parseInt(oldName.substring(oldName.length() - 3));
num++;
newName = oldName.substring(0, oldName.length() - 3) + String.format("%03d", num) + "."
+ FilenameUtils.getExtension(targetFile.getName());
newName = oldName.substring(0, oldName.length() - 3) + String.format("%03d", num) + "." + extension;
}
targetFile = new File(targetDir + "\\" + newName);
}
log.info("(AssetID " + assetId + ") Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'");
log.info("(AssetID " + assetId + ") Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'");
line[1] = targetFile.getName();
}