I think you might have misunderstood the intention. I know I can use local scripting and I do use it. The problem is with remote site. For example I want to transfer some local files into a directory called ~/ABC/DEF but it may or may not exist. There's no way to check its existence in local script. I could just call the mkdir command each time, but most of the time the directory already exists and this would cause an error (WinSCP exit code is the 1 and my script reports an error).
I understand. The link I've posted, shows how to do that.