Giter Club home page Giter Club logo

picture_namer's Introduction

picture_namer

This script prepends the directory name to each specified filetype along with a 5 digit number starting at "00000" eg: <directory_name>_<xxxxx>_<filename>. If there are already files with the <directory_name>_<xxxxx>_<filename> naming format in the directory then the script will count these files to prevent simultaneous use of the same numbers in the new filename. If there are more than 99999 files then the script will add more leading zeros. Spaces are changed into "_". Specified filetypes can be read from a text file or specified via the command line. I've only tested this using Windows 11.

picture_namer.py

This is the main script. I use Python 3.8.2 to run it. The script will ask for the path to where the files to be renamed are if no path is specified in the command line. If _list_of_filetypes.txt can't be found by the script the script will ask for a text file containing a list of filetypes. If the script cannot read the file in the location inputted it will run a default list of picture filetypes. The fallback default list of filetypes is: '.jpg', '.png', '.mp4', '.jpeg', '.dng', '.gif', '.nef', '.bmp' Default sort behavior is by date modified.

The following CLI arguments can be used if desired:

  • -m or --moddate: This sorts the files by modified date then prepends the directory name
  • -f or --filename: This sorts the files by filename then prepends the directory name
  • -p <directory_path> or --folderpath <directory_path>: Path to where files to be renamed are
  • -i or --input: This disables user input. Required if script is ran unattended. The script has the ability to ask for user input for the folder path or incase a list of filetypes can't be found. Default behavior has user input enabled.
  • l <file_path> or --list <file_path>: Specify a custom list of filetypes. Must be a .txt file containing one filetype per line. Comments can be included in the file using "#" or "//".
  • -e or --explicit: Script will not ignore letter case in the filetypes list. Default behavior is to ignore case in filetypes list.

picture_namer_gui.py

This contains the code used to for the GUI. The CLI arguments were copied into this file and slightly modified so they could be read by Gooey to create a GUI.

Check Gooey out here: https://github.com/chriskiehl/Gooey

_list_of_filetypes.txt

The script looks for this file in the same directory as the script then reads in the filetypes. I've populated it with picture and video filetypes and more can be appended. If this file is not present the script will ask for the location of a file. Comments can be included in the file using "#" or "//".

Warning: If a filetype is missing in the list then the numbering of the files will be incorrect since the script will not search for that filetype.

picture_namer_gui.exe

An executable is provided so the script doesn't have to be run via the command line using Python 3. This was built using Pyinstaller using the --onefile flag. The _list_of_filetypes.txt is packaged inside the binary. Therefore to add additional filetypes the binary will have to be rebuilt after the _list_of_filetypes.txt is modified or a custom list will have to be inputted.

Check out this answer by James on stackoverflow for interesting Pyinstaller path behavior:
https://stackoverflow.com/questions/51060894/adding-a-data-file-in-pyinstaller-using-the-onefile-option

build.bat

This runs the command that builds picture_namer.exe using the parameters specified in picture_namer_gui.spec. Pyinstaller and Python are required. The the build directory is automatically removed to clean up files.

picture_namer_gui.spec

This is the file that is used by Pyinstaller to build picture_namer_gui.exe. This has to be used due to the image_overides paramerter that allows Gooey to find the custom images.

images Directory

Directory containing custom images used in the GUI.

picture_namer's People

Contributors

sky5hr0ud avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.