powershell - How to -Include using a variable with multiple criteria -


i trying copy files names fulfills given set of criteria 1 folder another. this answer, found -include statement used this.

my issue need criteria user-specified (through variable), possibility of containing multiple criteria. is, try following:

# works fine $includefiles = "*tests.jar" copy-item "from/path" "to/path" -include $includefiles   # returns nothing $includefiles = "*tests.jar, other.jar" copy-item "from/path" "to/path" -include $includefiles  

how work around issue? somehow possible "destring" variable, use syntax or similar?

# works fine $copypattern = "*tests.jar", "other.jar" copy-item "from/path" "to/path" -include $copypattern 

the point argument -include array of strings, each string pattern include. way wrote require comma , space in file name. so, unless have such files, nothing included.

if positive pattern never include commas , you'd rather have single string, can of course convert array:

$copypatterns = "*tests.jar, other.jar" -split ', ' 

note parsing works differently in arguments commands, why following work well:

copy-item from/path to/path -include *tests.jar,other.jar 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -