title: Script to Search String and copy file(s) to another location
body: <p>I need to basically match files from one folder to folders on a network based on the string of the file name.</p>
  
  <p>The similarity in the file name will provide the destination folder that I need to copy the file from the source folder to.</p>
  
  <p>So Example:</p>
  
  <p>Folder on c:\</p>
  
  <p>C:\Testfile</p>
  
  <p>has a number of files that start with Cxxxxxx (these files are either pdf, JPG, xls or doc)</p>
  
  <p>I need to then copy the file from this location using the string of the name starting with Cxxxxxx</p>
  
  <p>To a folder on the network location:</p>
  
  <p>Network location:</p>
  
  <p>\mydomain\myshare\archive\</p>
  
  <p>the archive folder has many sub folders so i need to search the archive folder for the same string file name Cxxxxx once that file is found i need to copy the file from C:\Testfile to the found location.</p>
  
  <p>How i do this manually:</p>
  
  <p>I go into folder C:\Testfile I copy the file name C100001</p>
  
  <p>I then goto the network share:</p>
  
  <p>\mydomain\myshare\archive\</p>
  
  <p>And perform a search for C100001</p>
  
  <p>From the result i open up the location</p>
  
  <p>\mydomain\myshare\archive\2015\may\company\</p>
  
  <p>and paste the file C100001 to that location</p>
  
  <p>Unfortunately i have to do this with every file in c:\Testfile so a script to help with this would be greatly appropriated.</p>
  
  <p>I tried a simple code with batch file to find and copy an exact file from one location to another:</p>
  
  <pre><code>@echo off
  for /f "delims=" %%i in ('dir /s /b /a-d C:\Testfile\textfile.txt') do copy /b "%%~i" "C:\Testfile\Test 2"
  </code></pre>