Icons constantly changes to "generic" one

After updating to one of the recent versions of Ventura, I have faced a bug that happens about half of the time I edit and save txt files.

The bug is that the icon of a file become “generic”. For example, I have a file with six lines of text about using AppStore.

Here is how its icon looks normally:

enter image description here

And after I save it, it often changes to:

enter image description here

The current workaround to restore the “normal” icon is to rename the file, e.g. from appstore to appstore1 and then back to appstore. But after a week this really makes me angry. How to fix this?

I had this issue in an earlier OS. Relaunching the finder would return the icons to their correct state, but if I rebooted, they’d change back. Still quicker than renaming the files though.

Thanks, so we need a better solution.

I suppose the issue might be because the icons are cached, and the cache has been corrupted. And so deleting the cache might help. Haven’t tried this yet, though.

Update: I tried to clear the cache using the shell script Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock · GitHub, but this didn’t helped.

Yep, the icons are fixed, but after I save a file, its icon still replaced with a generic one.

So it seems the problem has gone for you, and you don’t need to relaunch Finder anymore? What was the solution?

I never did find a solution, but it went away on its own after an OS update.