I have Folder Country with subfolders USA, Europe, Asia. In every subfolder I have cities e.g C:\Country\USA\New York
I would like to copy all the files what are in subfolders to another destination. D:\Country\U\USA\New York. I have a lot of these files and try to figure out how to copy the files to the matching destination. So everything what is here C:\Country\USA\New York\ to D:\Country\U\USA\New York. Is there any easy way how to do it with powershell?
I have following code. The code will go through all folders and subfolders I need, that’s fine. I am struggling with definition of destination path. How can I achieve to find matching name in destination? For example at C:\ drive there is folder Country and subfolders Europe, USA, Asia. These subfolders contains other subfolders with City names. And I need that everything will be copied to the D:\ drive with matching names.On D:\ drive there is a different path USA D:\Country\U\USA\New York for Europe it is D:\Country\E\Europe\London etc.
one more thing, if I have for example on C:\Country\USA\New York but on “D:\Country\USA\New York - 20.9.2016”, how can I achieve to compare the text only before the dash. I need to copy everything from “New York” to “New York - 20.9.2016” I tried IndexOf but it didn’t work. Thanks a lot for any advice.