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
|
propMinSdkVersion = 21
|
||||||
propTargetSdkVersion = propCompileSdkVersion
|
propTargetSdkVersion = propCompileSdkVersion
|
||||||
propVersionCode = 1
|
propVersionCode = 1
|
||||||
propVersionName = '5.19.2'
|
propVersionName = '5.19.9'
|
||||||
kotlin_version = '1.3.50'
|
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?.baseConfig?.lastRenamePatternUsed = rename_items_value.value
|
||||||
activity?.handleSAFDialog(sdFilePath) {
|
activity?.handleSAFDialog(sdFilePath) {
|
||||||
ignoreClicks = true
|
ignoreClicks = true
|
||||||
|
var currentIncrementalNumber = 1
|
||||||
var pathsCnt = validPaths.size
|
var pathsCnt = validPaths.size
|
||||||
|
val numbersCnt = pathsCnt.toString().length
|
||||||
for (path in validPaths) {
|
for (path in validPaths) {
|
||||||
val exif = ExifInterface(path)
|
val exif = ExifInterface(path)
|
||||||
var dateTime = if (isNougatPlus()) {
|
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 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 simpleDateFormat = SimpleDateFormat(pattern, Locale.ENGLISH)
|
||||||
val dt = simpleDateFormat.parse(dateTime)
|
val dt = simpleDateFormat.parse(dateTime.replace("T", " "))
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
cal.time = dt
|
cal.time = dt
|
||||||
val year = cal.get(Calendar.YEAR).toString()
|
val year = cal.get(Calendar.YEAR).toString()
|
||||||
|
@ -88,6 +90,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
||||||
.replace("%h", hours, false)
|
.replace("%h", hours, false)
|
||||||
.replace("%m", minutes, false)
|
.replace("%m", minutes, false)
|
||||||
.replace("%s", seconds, false)
|
.replace("%s", seconds, false)
|
||||||
|
.replace("%i", String.format("%0${numbersCnt}d", currentIncrementalNumber))
|
||||||
|
|
||||||
if (newName.isEmpty()) {
|
if (newName.isEmpty()) {
|
||||||
continue
|
continue
|
||||||
|
@ -114,6 +117,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
|
||||||
newPath = "${path.getParentPath()}/$name~$currentIndex$extension"
|
newPath = "${path.getParentPath()}/$name~$currentIndex$extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentIncrementalNumber++
|
||||||
activity?.renameFile(path, newPath) {
|
activity?.renameFile(path, newPath) {
|
||||||
if (it) {
|
if (it) {
|
||||||
pathsCnt--
|
pathsCnt--
|
||||||
|
|
Loading…
Reference in a new issue