Small knitting in doing a small function, encountered a function, is to a directory of specified conditions in the file, moved to another directory. This is the demand, and then we will analyze how to achieve it.
First get a table of contents project, the first time can think of get-childitem, but we used too much, this small series want to change a pattern, we use Get-item, and then use wildcard characters to include all the subprojects. Of course, if you need to specify a file that matches the filename, you can use the matching rule directly here.
Then from the selected subprojects, filter the files in. This is also a very common function, that is to determine whether the Psiscontainer property is $false.
Finally, the filtered results are then move to another directory, of course, the use of Move-item this cmd-let.
So the final code is as follows:
Copy Code code as follows:
Get-item < path 1>\* | Where-object {$_. Psiscontainer-eq $false} | Move-item-destination < paths to another directory >
If your needs are slightly out of the small demo, but with this template, it should be easy to change the way you want it.