[Photo Organizer] [java] [windows] Move selected photos to a folder with 2 clicks

Sort the photos referenced in the photo viewer into the ★★★ folders.

Sorting photo files takes time and effort. It is Korejanai who forgets the number or tries to print it while selecting it. Or looking at unnecessary photos. I want to see only the files I need! What's more, I made something like this for my own convenience because I wanted to sort it out easily.

When you start this (★★★ .EXE) from the photo viewer, it will create ★★★ on the current folder and move it to ★★★.

For example

Suppose you have files from 001.JPG to 005.JPG with this folder structure.

CANON001/ └ jpg   ├ 001.jpg   ├ 002.jpg   ├ 003.jpg   ├ 004.jpg   ├ 005.jpg

In this state, if you start ★★★ while selecting 003.jpg in the photo viewer, a ★★★ folder will be created in the same row as JPG as shown below, and 003.jpg will be moved.

CANON001/ └ jpg   ├ 001.jpg   ├ 002.jpg   ├ 004.jpg   ├ 005.jpg ├ ★★★   ├ 003.jpg

Due to the characteristics of the photo viewer, the moved file will repeat the photos and images in the folder you are viewing, so you cannot see the moved file unless you change the folder you are viewing.

In other words, after moving, the photo viewer will only refer to the following files.

└ jpg   ├ 001.jpg   ├ 002.jpg   ├ 004.jpg   ├ 005.jpg

If you look at the images from the ★★★ folder after moving, you can see only the following files.

├ ★★★   ├ 003.jpg

Some preparations (environment where JAVA can be executed, revival of photo viewer) are required, but it is very easy to sort photos with just 2 clicks (1. Open → 2. ★★★).

20.jpg

Exe processing is carried out by launch4j etc. http://launch4j.sourceforge.net/

Refer to this area to enable the photo viewer. Editing the registry is quick and easy. https://popozure.info/20190823/14633

Download executable file

I'm sure you only want the executable file You can get the executable file by downloading it from here. https://drive.google.com/open?id=1dKcispHr8_D81kaPRgID7oKf27bEMfvS

Just in case, I will publish the source as well

starSelector.java


import java.io.*;
import java.util.logging.*;
public class starSelector {
  public static final String LOGFILE = "StarSelector.log";
  public static void main(String[] args) {
    try {
      final Logger logger = Logger.getLogger("starSelector");
      try {
        //Specify the output file
        FileHandler fh = new FileHandler("starSelector.log", true);
        //Specify the output format
        fh.setFormatter(new java.util.logging.SimpleFormatter());
        logger.addHandler(fh);
      } catch (IOException e) {
        e.printStackTrace();
      }
      File file = new File(args[0]);
      File parentDir = new File(file.getParent());
      //System.out.println("Parent parent directory name: " + parentDir.getParent());
      String strParentDir = file.getParent();
      String strFileName = file.getPath();
      String strStarDir = "★★★";
      File moveNewFolder = new File(parentDir.getParent() + "\\" + strStarDir);
      //Read file check
      if (!file.exists() || !file.canRead()) {
        logger.log(Level.WARNING, "The specified file does not exist");
        return;
      }
      if (file.getParent() == null) {
        logger.log(Level.INFO, "The file in the Home directory is specified. Cannot specify the parent directory");
        return;
      }
      //Diretry check
      if (parentDir.getParent() == null) {
        logger.log(Level.INFO, "The file in the Home directory is specified. Cannot specify the destination folder");
        return;
      }
      moveNewFolder.mkdir();
      //File movement implementation
      File file2 = new File(parentDir.getParent() + "\\" + strStarDir + "\\" + file.getName());
      try {
        if (file.renameTo(file2)) {} else {
          logger.log(Level.WARNING, "Failed to move file");
        }
      } catch (SecurityException e) {
        logger.log(Level.WARNING, e.toString());
      } catch (NullPointerException e) {
        logger.log(Level.WARNING, e.toString());
      }
    } catch (ArrayIndexOutOfBoundsException err) {
      System.out.println("How to use: java starSelector <Files to move>");
      return;
    }
  }
}

Recommended Posts

[Photo Organizer] [java] [windows] Move selected photos to a folder with 2 clicks
Java program to resize a photo into a square with margins
[Java] How to create a folder
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Until you run a Java program with the AWS SDK local to Windows
I tried to break a block with java (1)
Submit a job to AWS Batch with Java (Eclipse)
[Java] How to start a new line with StringBuilder
Deploying a Java environment with Windows Subsystem for Linux (WSL)
I tried to create a java8 development environment with Chocolatey
[Beginner] Try to make a simple RPG game with Java ①
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
How to move another class with a button action of another class.
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
Build a Node-RED environment with Docker to move and understand
A memo to start Java programming with VS Code (2020-04 version)
Java to play with Function
Connect to DB with Java
Connect to MySQL 8 with Java
A story that I struggled to challenge a competition professional with Java
How to automatically operate a screen created in Java on Windows
Connecting to a database with Java (Part 1) Maybe the basic method
Replace with a value according to the match with a Java regular expression