There have been a few discussions here regarding file naming schemes, but having settled on the way I name my files (and folders), I am now thinking about workflows related to actually getting the files named properly. I am throwing out my thoughts for commentary and suggestions.
I find that I do a fair amount of renaming files once they have been created. On the surface, one might just argue to name everything according to the correct schema at the time of file creation, and I do try to do that to some extent, but I have found that I have to do a lot of renaming for a number of reasons:
-
Files downloaded from the internet or received from others (eg via email) obviously do not follow my file naming protocol. Yes, I do use an extensive set of Hazel rules that can handle things that are regularly downloaded such as utility bills, credit card bills, and the like, but there are some of these that for various reasons Hazel cannot handle (yet) because of difficulties finding the right date in the file contents or similar reasons. Eventually I will likely solve those problems, but of course new ones will arise. Many downloads are also "one offs’ and obviously I’m not going to have a Hazel rule for those files.
-
My file naming schema is very helpful (to me) once the files are renamed, but is unfortunately not very conducive to actual typing. My schema for most files is that the file starts with a date in YYY-MMDD format, then an underscore, and then descriptive information in the file, followed by the file extension. There are no spaces in file names; instead I use underscores, because I do enough at the command line to not want to deal with the hassle of file names with spaces. File names use only lowercase characters. In actual typing, however, it is far faster for me to type a description file name with spaces followed by a date in YYYY.MMDD format, however - it just works better on the keyboard. Sometimes, as a longtime touch typist, I just automatically capitalize things as well.
I have a utility program I wrote that can take most filenames that I have typed and intelligently convert them to the proper format, and one way that I do a lot of file renaming is to select multiple files in Finder and use a KM macro that uses my utility to generate the new file names and then rename the files. This is not a bad solution and actually works pretty well for me most of the time.
In my never-ending question to create workflows, sometimes even when there is no more efficiency to be gained, I was toying with another idea, to scan a folder and generate a BBEdit document listing the filenames. I can then type replacement file names, optionally tags to be added to the files, and then execute another script to parse the BBEdit document and do the renaming and tagging.
For example, here an off-the-cuff zsh script:
#!/bin/zsh
(printf "%s\n" "$1" ; find "$1" -depth 1 -exec basename {} \; | grep '^[^.].*' | \
while read LINE
do
b=$(basename ${LINE})
if [[ -d ${LINE} ]]
then
n=$(echo ${b} | camelcase)
else
n=$(formatfilename -d creation -l "${LINE}")
fi
printf "%40s --> %40s []\n" "${b}" "${n}"
done ) | bbedit
(camelcase is my utility to properly CamelCase folder names; formatfilename is my utility to build file names. The -d creation part tells it that if there is no date at the end of the filename, use the file’s creation date or content creation date in the new filename, and -l forces all characters to lowercase. There are other options to this program for different uses that I have for it.)
Taking as input a path to a folder, this script writes to a BBEdit document the folder path, and then on each line below is output of the format:
current_file_name --> suggested_file_name []
For Folders, the suggested_file_name is actually a suggested rename for the folder, as for folders I use CamelCase with no spaces (and a few quirks with dates that aren’t important here), and that’s done in the part of the script with if [[ -d ${LINE} ]]
.
The empty brackets are for typing tags, comma separated, to be added to the file as well, Of course, if the current and suggested file names are the same, no rename is done, and if the tags bracket is empty, no tags are added.
I haven’t written the back end script yet as I haven’t quite decided if this is the wrong way to go and/or more effort than it is worth (the script writing is minimal effort; it’s the actually usage that might not be worth the effort).
On the other hand, the idea that files are just created with whatever name is handy, including when scanning (which generates a lot of my files that need renaming later), and then I can run through all the renaming at one time for a batch of files, seems like a good way to go. By analogy, the idea of capturing ideas into OmniFocus’ Inbox and later reviewing the Inbox to create projects and tasks, or importing data in DevonThink’s Inbox and later processing into databases and folders.
I would be interested in thoughts. Is this a useful endeavor or am I heading down a road to nowhere once again?