I am trying to move some files to a relative subfolder recursivly.
I want to use the get-location
command and combine it with a string ( "\foo_1" ), while using it as a parameter.
So get-location
should result in " D:\foo_2 " so that the result is " D:\foo_2\foo_1 "
All while being a parameter of a separate command:
Get-ChildItem -Path ".\*.wav" -Recurse | Move-Item -Destination (get-location + "string")
I know i could just use variables, but i really want to understand this (if there is an answer). Thanks in advance =)
You could use a sub-expression, like this:
Get-ChildItem -Path ".\*.wav" -Recurse |
Move-Item -Destination "$(Get-Location)\foo_1"
The structure $(...)
tells PowerShell to execute the contents of the brackets first (ie run Get-Location
) then substitute the result into the string. Note that you must use double-quotes as this functionality doesn't work with single-quoted strings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.