Reputation: 11
The solution here works for me if the command is executed at a command prompt:
Copy files without recreating subdirectories
However, I get an error if the command is in a batch file:
"The following usage of the path operator in batch-parameter substitution is invalid %~nf"
How do you code this in Powershell?
Upvotes: 1
Views: 305
Reputation: 301357
Replace any %
with %%
in a bat file.
So %~nf
becomes %%~nf
Powershell equivalent:
gci -r .\test | ?{-not $_.PsIsContainer} | copy-item -Destination .\test2
Upvotes: 4