Score:0

How to merge two data sources with slightly different folder names

cn flag

How can I copy all .msg files that are spread throughout some GUID sub-folders in one folder to another folder that has a slightly different folder name at the end. Is it possible?

So for example:

  • Source
  • c:\Folder A\16-1167 Contoso 1 Hacker Way\Correspondence
  • c:\Folder A\16-1168 Company name, address\Correspondence
  • Destination:
  • C:\Folder B\16-1167\0ba45cbd-6da8-4a4c-ae1c-9aca13aab1db\1\filename.msg
  • C:\Folder B\16-1167\971d6bd3-d4f0-478d-b12d-ba0f9f1ea088\1\random filename.msg
  • c:\Folder B\16-1168\971d6bd3-d4f0-478d-b12d\1\email.msg etc

I want to use a program or a script to copy all the *.msg into one folder in the source. It's complicated by the fact that the source has a job name after the job number. So the first 7 characters of the folder name are identical but the ending isn't.

us flag
Yes, this is certainly possible by using regular expression to extract desired part of the path to a variable. In Windows, you could use PowerShell to write such a script.
cn flag
can you give an example?
us flag
This site is not a script writing service. You should try writing the script yourself, and if you cannot get it to work, then ask for help here why it doesn't work.
cn flag
I guess you don't really know what you are talking about then.
cn flag
https://pastebin.com/tJE1WAy9 Kind of got it working but it doesn't copy the .msg files from each job folder to the job folder, it dumps every msg into the root of A. Can anyone offer a solution?
us flag
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.1 explains how to use regular expression in PowerShell. You need to capture part of the string and use that part in the destination.
cn flag
Thanks for the tip.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.