Get-ChildItem -Include and -exclude with multiple file extensions
On day I was writing a PowerShell script to streamline my photography workflow. I would like to copy the photo files including the RAWs from memory card to the hard drive, and put them into the the folders named by the date of shooting. I decided to filter early in the Get-ChildItem so it only checks the photo related files* and skip others. The Get-ChildItem has the -Include syntax suit the purpose well. However, there was a tiny rock in the way: getting the multiple file extensions work with the -include parameter. In the shell, following worked fine: But when the '*.jpg, *.cr2' was saved in to a variable, $list, for the script, Get-ChildItem returned nothing. Saving them into an array worked for the script. See the list below. Well, the full help of Get-ChildItem did tell me that it wants String[] for the -include parameter. But what interested me was why? I then ran the tracing in each scenarios. Please have a look of each screenshot below. In scenari