This is an interesting challenge! Normally I would approach this by creating a custom script that uses the Admin API to update the metafields, but given Shopify has been making improvements to Flow as of late I gave it a shot as you wanted to know how to do it in Flow and found out it was possible.
The workflow I created is only working with the Diameter metafield but can be augmented to work with other ones as well.
(Check the image at the bottom of my response for seeing how the final flow looks like)
We are using “Product created” as a trigger because there isn’t a “Manual trigger” option yet added to the Flow app, but we’ll be running this manually anyways as you’ll see later.
The most complex part here happens inside that Run code action
The input of that action should be
query{
product {
tags
}
}
The output should be
"The output of Run Code"
type Output {
diameter: Int
}
And the code should be
export default function main(input) {
const tags = input.product.tags;
let result = {
}
for(const tag of tags){
if(tag.startsWith("diameter-")) {
result.diameter = tag.split("diameter-")[1];
}
}
return result;
}
Explanation: there we are querying the product tags and running some code to loop through each one and check if there’s one that starts with diameter-, if there is we are removing that first part (so for example in diameter-2 we remove diameter- and just keep the 2) and return that in the result of this action.
Then add a condition to check if the Run code action returned a diameter. If it did then use the “Update product metafield” action to update the diameter metafield
After giving that workflow a name and saving you can now go to Products in the admin, select all your products, click on the 3 dots and select “Run Flow Automation” (see second part of attached image at the end of this post if you can’t find the “Run flow automation” button)
From there select the one you just created and click “Run workflow”
To support other product tags the Run code action would need to be updated but the idea is roughly the same as what’s already there.