CropAssetCopyTool
This commit is contained in:
@@ -155,19 +155,19 @@ public class CropAssetCopyTool {
|
|||||||
if (targetFile.exists()) {
|
if (targetFile.exists()) {
|
||||||
while (targetFile.exists()) {
|
while (targetFile.exists()) {
|
||||||
String oldName = FilenameUtils.removeExtension(targetFile.getName());
|
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) == '-'
|
if (oldName.length() > 5 && oldName.charAt(oldName.length() - 4) == '-'
|
||||||
&& oldName.charAt(oldName.length() - 3) == '-'
|
&& oldName.charAt(oldName.length() - 3) == '-'
|
||||||
&& StringUtils.isNumeric(oldName.substring(oldName.length() - 3))) {
|
&& StringUtils.isNumeric(oldName.substring(oldName.length() - 3))) {
|
||||||
int num = Integer.parseInt(oldName.substring(oldName.length() - 3));
|
int num = Integer.parseInt(oldName.substring(oldName.length() - 3));
|
||||||
num++;
|
num++;
|
||||||
newName = oldName.substring(0, oldName.length() - 3) + String.format("%03d", num) + "."
|
newName = oldName.substring(0, oldName.length() - 3) + String.format("%03d", num) + "." + extension;
|
||||||
+ FilenameUtils.getExtension(targetFile.getName());
|
|
||||||
}
|
}
|
||||||
targetFile = new File(targetDir + "\\" + newName);
|
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();
|
line[1] = targetFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user