Implementing "--parent" switch of the Linux "cp" command in a Windows batch script

The point of the "--parent" switch is to copy a file (or a directory) with it's parent directory structure to another directory. This is not exactly a trivial task in a Windows batch file and as such, it's a great opportunity to introduce some not very widespread features of the command prompt (eg. setlocal/endlocal, the "&" command separator, string operations).

Did I already mention that Windows sux? Sad
Batch scripting is so clumsy ... you have to write dozens of lines to get something that you can do within one line in any standard Unix/Linux shell. Shock

cp_wp.cmd1.29 KB