Thanks in advance for the help. I’ve searched the forums but I’m afraid my level of scripting knowledge is just not always up to what I’m seeing and would be grateful for more specific advice.
I’m trying to import and organize large PDFs of archival images (handwritten, so can’t extract useful info via OCR). Each PDF filename begins with a number string followed by an underscore—say, “123456_Records of… .” On import to the Global Inbox, I want DT to 1) move these items to my Sources database and 2) move them to a Group according to their numeric prefix in the file name (which is a unique ID for the archival series from which they came) AND if the group doesn’t exist, to create a group and then move the file. I imagine that the Group names will be only these numbers, since the rest of the file name will vary. Ideally, for the filename example above, it would end up in a Group named “123456” and any subsequent files beginning with “123456” would also end up in that group. These numeric prefixes are not always the same length, but in the file name, they will always be followed by an underscore and a string of characters (and then maybe more numbers). I tried to get chatGPT to write an Applescript but it didn’t seem to work…and I couldn’t understand enough of it to use it as a template with some edits. I imagine that because of the “create Group” action, this needs to be scripted, but perhaps it’s simple enough that it’s something that could be done in a Smart Rule with placeholders?
This is actually easily accomplished via a smart rule with no programming required.
- This excludes subgroups so it doesn’t match already filed items.
- Scan name matches the asterisk and ignores everything else.
- Control-click the text field in the File action and choose Insert Placeholder > Document String to use the matched string.
These documents were filed with this smart rule into their respective groups…
I tried to get chatGPT to write an Applescript but it didn’t seem to work
While this may seem reasonable, I would recommend against it, especially as you essentially learn nothing from it and is likely incorrect or not optimized.
Thank you so much! I can see why this should work—but I don’t seem to have been able to implement it correctly. I have moved this rule to be the first in my list of Smart Rules, right-clicked and said “Apply Rule.” There are 37 items that appear to meet the criteria for the Rule but when I say “Apply,” nothing seems to change. The little exclamation mark triangle that seems to list errors is greyed out and nothing appears in the ‘Activity’ box below the Smart Rules list. Perhaps I should quit and restart? Attached is a screenshot of how I have implemented the rule and in the background are the files that appear for this rule.
(I recognize that not all of them have the underscore—I’m still working through building my conventions and I don’t expect it to move those!). I should also add that the “Research” tag is applied by Hazel upon moving files into the DT Global Inbox so all these items should have it.
You’re seeing the files that the smart group conditions are matching. So, nothing’s going to change there unless you (eg) change the file names so they no longer match the condition.
See if you have the groups now that you’re expecting to have same if they contain the files they should contain.
Aha—I’ve learned something new about Smart Rules. I do not see that any new groups have been created in the Sources2 database where I want them. I do see that new groups have been created in an Inbox (inside the Global Inbox but not the database Inbox?) but given the behavior of these groups (each file seems to have a group, rather than files with the same prefix being in a single group), I am thinking that they were perhaps created by a previous attempt at this rule and not by BLUEFROG’s elegant formulation.
Screenshot showing the inboxes and the groups there:
If you are not intending to file things into subgroups of the Global Inbox, you need to add a Move action and move it to the destination database before you file.
Also, you should be as specific as possible when setting the criteria for a smart group or smart rule. This minimizes the possibility of acting on items that don’t need to be processed.
Also also the groups in your screencap aren’t the ones from my smart rule, correct?
I did originally have a rule to move files tagged Research to Sources2, but it didn’t seem to be working. I also had as part of the rule to OCR incoming PDFs, which I’ve now removed because I think I was dumping too much data into DT for it to effectively process—I will OCR as needed until I have a better sense of how DT works and what I’m asking from it. Once DT has finished processing its backlog of things, I will test these rules.
In terms of best practices, do you have a recommendation as to whether the “Move to Sources” and “File to” actions should be part of the same rule, or two different rules (given that they are acting on the same set of files, my inclination is for a single rule?)
Many thanks for the speedy assistance! I’ve made more progress in the last few hours than in the last few days.
Add the Location column heading to the view of your smart rule.(right click on Name or Modified or Kind and select Location).
That way you can quickly see where the items that match your smart rule actually reside before and after you run the rule.
Yes, you should Move then File in the same smart rule unless you had an actual need to split them into two.
Thank you for this! It took me a minute to figure out what you meant—but I’ve got it (and learned a little more about the different parts of DT’s interface in the process ) For anyone else who comes across this, I believe this window is called the ‘search pane’ in the Help guide.
Note though that column headings are available in any List view in the main window.
You can choose which metadata you want to see in a wide variety of ways.