Sometimes it is useful to have image size written in filename (I needed it when I was browsing my collection of wallpapers). I could not find any tool which would automate this process, so I have decided to write one. Probably it is job for bash or Python but I like Java most, so it is Java CLI tool. I have used ImageInfo class to get image parameters.
That’s what it does:
- scans all parameters for options – there is only one valid option: -p which switches the tool from the dry mode (tool only shows what should be done) to the working mode
- for every non-option parameter:
- check if it is path to an image
- read image width and height from the file
- check if the file name already contains valid info about the image size
- if need be, remove invalid info from the file name
- put WIDTHxHEIGHT string at the beginning of the file name
Use it like this:
# to preview changes:
$ java -jar /some-path/into-filename.jar file1 file2 ... # you can use full file paths
# to rename files:
$ java -jar /some-path/into-filename.jar <strong>-p</strong> file1 file2 ...
And here is the jar: into-filename (Public Domain License)