Created
October 25, 2022 03:08
-
-
Save eboudrant/3735d050ab5984ba147a9ad4a75c2966 to your computer and use it in GitHub Desktop.
Re-order GoPro files in alphabetical order (renaming)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Re-order GoPro files in alphabetical order (fine rename) | |
// Probably does not cover all use cases. | |
// more info about GoPro naming can be found here https://community.gopro.com/s/article/GoPro-Camera-File-Naming-Convention?language=en_US | |
import java.io.File | |
fun main(args: Array<String>) { | |
val dir = File("PATH_TO_DIR_CONTAINS_MP4_FILES") | |
dir.listFiles { dir, name -> | |
val part1 = name.substring(0, 4) | |
val part2 = name.substring(4, name.lastIndexOf(".")) | |
if (part1.startsWith("GX") || part1.startsWith("GH")) { | |
val index = part1.substring(2, 4) | |
val newName = "VIDEO_${part2}_$index.MP4" | |
println("$dir/$newName") | |
File(dir, name).renameTo(File(dir, newName)) | |
} | |
true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment