Add project files

This commit is contained in:
Bea 2022-06-01 00:38:54 +02:00
parent 456ddb41a1
commit 202e600a1e
4 changed files with 196 additions and 0 deletions

59
.gitignore vendored Normal file
View File

@ -0,0 +1,59 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/
target/
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

65
pom.xml Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Renamer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.32.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.eamonnmcmanus/serialysis -->
<dependency>
<groupId>io.github.eamonnmcmanus</groupId>
<artifactId>serialysis</artifactId>
<version>0.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-my-bundle</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.example.Renamer</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,72 @@
package org.example;
import java.io.File;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Renamer
{
/*
this simple and inefficient program was made to rename files in a folder that were numbered incorrectly.
the files had the correct number in their name, but since most OSes use alphabetical order, it was not like this:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
but like this:
1, 10, 11, 12-19, 100, 101, 102... 2, 20, 21-29, 200, 201, 202...
this is easily fixed by adding zeros before the actual number, up to the number of needed digits:
001, 002, 003, 004... 010, 011... 020, 021... 100, 101...
*/
public static String path = "D:\\CD 2021\\foto";
public static void main(String[]args)
{
Set<String> listaFoto = listFilesUsingJavaIO(path);
System.out.println(listaFoto.toString());
for(String currentFile : listaFoto)
{
System.out.println("Orig: " + currentFile);
System.out.println("Nums: " + currentFile.replaceAll("[^\\d]", ""));
String onlyNumbers = currentFile.replaceAll("[^\\d]", "");
String everythingElse = currentFile.replaceAll("[\\d]", "");
if(onlyNumbers.length() >= 3 || onlyNumbers.length() == 0) continue;
String newName = "";
if(onlyNumbers.length() == 2)
{
System.out.println("size 2");
newName = "0" + onlyNumbers;
}
else
if(onlyNumbers.length() == 1)
{
System.out.println("size 1");
newName = "00" + onlyNumbers;
}
else newName = onlyNumbers;
newName = newName + everythingElse;
System.out.println("New: " + newName);
File original = new File(path + "\\" + currentFile);
File destination = new File(path + "\\" + newName);
original.renameTo(destination);
}
}
public static Set<String> listFilesUsingJavaIO(String dir) {
return Stream.of(new File(dir).listFiles())
.filter(file -> !file.isDirectory())
.map(File::getName)
.collect(Collectors.toSet());
}
}

View File