Package: jdfile
jdfilejdfilecleans and normalizes filenames. In addition, if you have directories which follow theJohnny Decimal, jdfile can move your files into the appropriate directory.jdfilecleans filenames based on your preferences.Remove special charactersTrim multiple separators (word----wordbecomesword-word)Normalize tolower case,upper case,sentence case, ortitle caseNormalize all files to a common word separator (_,-,)Enforce lowercase file extensionsRemove common English stopwordsSplitcamelCasewords into separate words (camel Case)Parse the filename for a date in many different formatsRemove or reformat the date and add it to the the beginning of the filenameAvoid overwriting files by adding a unique integer when renaming/movingClean entire directory treesOptionally, show previews of changes to be made before commitingIgnore files listed in a config file by filename or by regexSpecify casing for words which should never be changed (ie.iMacwill never be re-cased)jdfilecan organize your files into folders.Move files into directory trees following theJohnny DecimalsystemParse files and folder names looking for matching termsUsesnltkto lookup synonyms to improve matchingAdd.jdfilefiles to directories containing a list of words that will match filesWhy build this?It's nearly impossible to file away documents with normalized names when everyone has a different convention for naming files. On any given day, tons of files are attached to emails or sent via Slack by people who have their won way of naming files. For example:department 2023 financials and budget 08232002.xlsxsome contract Jan7 reviewed NOT FINAL (NL comments) v13.docxJohn&Jane-meeting-notes.txtProject_mockups(WIP)___sep92022.pdfFIRSTNAMElastname Resume (#1) [companyname].PDFcode_to_review.jsIf you are a person who archives documents there are a number of problems with these files.No self-evident way to organize them into foldersNo common patterns to search forDates all over the place or nonexistentNo consistent casingNo consistent word separatorsSpecial characters within textI could go on and on...Additionally, even if the filenames were normalized, filing documents manually is a pain.jdfileis created to solve for these problems by providing an easy CLI to normalize the filename and organize it into an appropriate directory on your computer.Installjdfile requires Python v3.10 or abovepipinstallpipinstallobsidian-metadataUsageRunjdfile --helpfor usageConfigurationTo organize files into folders, a validtomlconfiguration file is required at~/.jdfile/jdfile.toml# The name of the project is used as a command line option.# (e.g. --organize=project_name)[project_name]# (Required) Path to the folder containing the Johnny Decimal projectpath="~/johnnydecimal"# An optional date format. If specified, the date will be appended to the filename# See https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes for details on how to specify a date.date_format="None"# Ignores dotfiles (files that start with a period) when cleaning a directory.  true or falseignore_dotfiles=true# Files in this list will be skipped.ignored_files=['file1.txt','file2.txt']# File names matching this regex will be skipped.# IMPORTANT: You must double escape within the patternignored_regex=[".*\\.tar.gz$"]# Force the casing of certain words. Great for acronyms or proper nouns.match_case=["CEO","CEOs","iMac","iPhone"]# Overwrite existing files. true or false. If false, unique integers will be appended to the filename.overwrite_existing=false# Separator to use between words. Options: "ignore", "underscore", "space", "dash", "none"separator="ignore"# Split CamelCase words into separate words. true or falsesplit_words=false# Optional list of project specific stopwords to be stripped from filenamesstopwords=["stopword1","stopword2"]# Strip stopwords from filenames. true or falsestrip_stopwords=true# Transform case of filenames.# Options: "lower", "upper", "title", "CamelCase", "sentence", "ignore",transform_case="ignore"# Use the nltk wordnet corpus to find synonyms for words in filenames. true or false# Note, this will download a large corpus (~400mb) the first time it is run.use_synonyms=falseExample usage# Normalize all files in a directory to lowercase, with underscore separators$jdfile--case=lower--separator=underscore/path/to/directory# Clean all files in a directory and confirm all changes before committing them$jdfile--clean/path/to/directory# Strip common English stopwords from all files in a directory$jdfile--stopwords/path/to/directory# Transform a date and add it to the filename$jdfile--date-format="%Y-%m-%d"./somefile_march3rd,2022.txt# Print a tree representation of a Johnny Decimal project$jdfile--project=[project_name]--tree# Use the settings of a project in the config file to clean filenames without# organizing them into folders$jdfile--project=[project_name]--no-organizepath/to/some_file.jpg# Organize files into a Johnny Decimal project with specified terms with title casing$jdfile---project=[project_name]--term=term1--term=term2path/to/some_file.jpgTipsAdding custom functions to your.bashrcor.zshrccan save time and ensure your filename preferences are always used.# ~/.bashrcifcommand-vjdfile&>/dev/null;thenclean(){# DESC:	 Clean filenames using the jdfile packageif[[$1=="--help"||$1=="-h"]];thenjdfile--helpelsejdfile--sep=space--case=title--confirm"$@"fi}wfile(){# DESC:	 File work documentsif[[$1=="--help"||$1=="-h"]];thenjdfile--helpelsejdfile--project=work"$@"fi}fiCaveatsjdfileis built for my own personal use. YMMV depending on your system and requirements. I make no warranties for any data loss that may result from use. I strongly recommend running in--dry-runmode prior to updating files.ContributingSetup: Once per projectThere are two ways to contribute to this project.1. Local developmentInstall Python 3.10 andPoetryClone this repository.git clone https://github.com/natelandau/jdfile.gitInstall the Poetry environment withpoetry install.Activate your Poetry environment withpoetry shell.Install the pre-commit hooks withpre-commit install --install-hooks.2. Containerized developmentClone this repository.git clone https://github.com/natelandau/jdfile.gitOpen the repository in Visual Studio CodeStart theDev Container. RunCtrl/⌘+⇧+P→Remote-Containers: Reopen in Container.Runpoetry env info -pto find the PATH to the Python interpreter if needed by VSCode.DevelopingThis project follows theConventional Commitsstandard to automateSemantic VersioningandKeep A ChangelogwithCommitizen.When you're ready to commit changes runcz cRunpoefrom within the development environment to print a list ofPoe the Poettasks available to run on this project. Common commands:poe lintruns all linterspoe testruns all tests with PytestRunpoetry add {package}from within the development environment to install a run time dependency and add it topyproject.tomlandpoetry.lock.Runpoetry remove {package}from within the development environment to uninstall a run time dependency and remove it frompyproject.tomlandpoetry.lock.Runpoetry updatefrom within the development environment to upgrade all dependencies to the latest versions allowed bypyproject.toml.