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?
- c:\s1_d1111_c1_p1.mpz needs move folder c:\snc1111
- 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
Post a Comment