How can I select a particular function to run based on a filename using Powershell? -


i have function change filename , move specific computer. function duplicated computer, have 2 specific functions each filename. can't seem figure out how script choose function want use. here i've tried no luck:

$files = dir -path \\server\pptv\*\*.* -include atrium.*, clirel.* -recurse {             (if ($file.fullname -eq "atrium.*" | rename-copy-atrium),      (if ($file.fullname -eq "clirel.*" | rename-copy-clirel))) } 

how can pipe function , run? rename-copy-atrium example 1 of function names.

the proper syntax if() statement in powershell is:

if([condition]) {     [execute code] } 

so want like:

$files = dir -path \\server\pptv\*\*.* -include atrium.*, clirel.* -recurse   foreach($file in $files) {     if($file.fullname -like "atrium.*")      {         # assume function takes fileinfo object parameter argument         rename-copy-atrium $file      }     elseif($file.fullname -like "clirel.*")     {         rename-copy-clirel $file      } } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -