I can try... since I already removed the datapack from my game I can now simulate what needs to be done. Ok, first things first, a better folder structure because the above one sucks. Yah, when you're typing you can uses spaces and I didn't realize all the indention would get removed. So lets fix that first:
+ datapacks/
++ diamondcounter
++++ pack.mcmeta
++++ data/
++++++ dia/
++++++++ advancements/
++++++++++ counter.json
++++++++ functions/
++++++++++ add.mcfunction
So: create the directory structure in the datapacks folder for whatever world save you want to use (you'll find those in the saves subfolder within your Minecraft program folder, on Windows this is in: "
%appdata%\.minecraft". (open your filemanager ('explorer'), and paste that bold stuff in the address bar, you'll see)). I strongly suggest you set this up while the game isn't running (or at least without having your world loaded / active).
In this example I've used "diamondcounter" instead of "diamond_count", that's because the name of this folder is completely unimportant. It's the stuff underneath which is...
Lessee, hopefully this also helps:

"data\dia" basically means that the data directory is empty apart from the dia subfolder, that's why they added it together.
diamondcounter only contains the 'pack.mcmeta' file and the 'data' subfolder. The 'data' subfolder only contains 2 other subfolders namely 'advancements' and 'functions'. Then 'advancements' contains the file 'counter.json' and 'functions' contains 'add.mcfunction'.
NOW.. once you set this up then load your world and run this command: "
/datapack list":

Don't mind the other datapacks, it's about
file/diamondcount here. (I just discovered a new OptiFine feature: the inability to save screenshots, "fun").
Then you give yourself a diamond and... I see what you mean. My bad! 😒
Yes, before you can use the setup you need to add the scoreboard objective yourself: "
/scoreboard objectives add dia_count dummy". I completely forgot about that... 🤦♂️ I was looking into "
minecraft:load", which is a function that gets executed as soon as you load a datapack but couldn't easily add something to check for the existence of the scoreboard objective, and I definitely didn't want to "just" create the objective even if it already existed because that would always generate an error message.

See? Don't mind the other scoreboards, this world is filled with all sorts of stuff.
Hopefully this cleared things up a bit... so, you need to create the scoreboard objective yourself ("
/scoreboard objectives add dia_count dummy") and then you should be good to go. This command is only needed
once, the objective gets saved with your world (as you can see in the above screenshot, I merely loaded it to verify what was going on).