The command in that thread doesn't work because it's, well, incorrect. The person who posted it was just guessing, and wondering why it didn't work. (I've fixed the linebreaks in the other thread, too.)
A working method can be found here:
I'd recommend not using the Select command for this at all. It's the wrong tool for the job. If you want a command to act on a file/folder/path, other than the things that are selected when you click the button, then you should usually feed the path to the command and not try to change the selection using the Select command.
That can be done using an explicit path or wildcard, with many commands, or via scripting if needed. With scripting, you have full control over the list of paths each command acts on.
(Scripts can also run the Select command and then request an updated snapshot of the selection afterwards, although I still would not recommend doing that as it's still going to mess around with the user's selection for what is really internal script variables/logic. A general rule is: Don't use the user's selection, or clipboard, or anything like that, to store what are effectively script/command variables, as it is annoying to run a command and have it trash state it didn't need to modify.)
There may be some cases where using Select makes sense or is easier, but they are not the norm and you shouldn't go to it as your first choice in trying to solve this kind of thing. That's not what it's for.
The Select command is for changing what the user sees is selected, and what subsequent buttons which the user clicks will act on. It is not for a button or script to modify the inputs to subsequent commands in the same button or script.