How do I write a batch file that moves files to directories where part of the filename matches the folder destination? -


i have lots of files need go in specific folders. filenames have pattern them , folders need hold them. how can write batch file following rule?

  1. c:\s1_d1111_c1_p1.mpz needs move folder c:\snc1111
  2. c:\s1_d2222_c1_p1.mpz needs move folder c:\snc2222

the filenames have 4 digits correspond folder. number after s , c 1, , p can have whole number after it.

this windows server 2008 r2 standard

thanks help!

using powershell sample move files startin in jdk child folder jdk

$files = get-childitem -file ($i=0; $i -lt $files.count; $i++) {     $outfile = $files[$i].name     if ($outfile.startswith("jdk")){         mkdir -path "jdk" -force         move  $files[$i].fullname "jdk"     } } 

modify match condition , paste code in powershell window


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -