implement the incrementing number at pattern renaming
This commit is contained in:
parent
5ed867ba90
commit
a4d2ad8346
2 changed files with 6 additions and 2 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.19.2'
|
||||
propVersionName = '5.19.9'
|
||||
kotlin_version = '1.3.50'
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,9 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
|||
activity?.baseConfig?.lastRenamePatternUsed = rename_items_value.value
|
||||
activity?.handleSAFDialog(sdFilePath) {
|
||||
ignoreClicks = true
|
||||
var currentIncrementalNumber = 1
|
||||
var pathsCnt = validPaths.size
|
||||
val numbersCnt = pathsCnt.toString().length
|
||||
for (path in validPaths) {
|
||||
val exif = ExifInterface(path)
|
||||
var dateTime = if (isNougatPlus()) {
|
||||
|
@ -71,7 +73,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
|||
|
||||
val pattern = if (dateTime.substring(4, 5) == "-") "yyyy-MM-dd kk:mm:ss" else "yyyy:MM:dd kk:mm:ss"
|
||||
val simpleDateFormat = SimpleDateFormat(pattern, Locale.ENGLISH)
|
||||
val dt = simpleDateFormat.parse(dateTime)
|
||||
val dt = simpleDateFormat.parse(dateTime.replace("T", " "))
|
||||
val cal = Calendar.getInstance()
|
||||
cal.time = dt
|
||||
val year = cal.get(Calendar.YEAR).toString()
|
||||
|
@ -88,6 +90,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
|||
.replace("%h", hours, false)
|
||||
.replace("%m", minutes, false)
|
||||
.replace("%s", seconds, false)
|
||||
.replace("%i", String.format("%0${numbersCnt}d", currentIncrementalNumber))
|
||||
|
||||
if (newName.isEmpty()) {
|
||||
continue
|
||||
|
@ -114,6 +117,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
|||
newPath = "${path.getParentPath()}/$name~$currentIndex$extension"
|
||||
}
|
||||
|
||||
currentIncrementalNumber++
|
||||
activity?.renameFile(path, newPath) {
|
||||
if (it) {
|
||||
pathsCnt--
|
||||
|
|
Loading…
Reference in a new issue