Wildcard (*) in the path don't work while copy

2019-06-10 08:03发布

问题:

There is a file (abc.txt) in a folder- C:\vackwrk\24may\abc.txt

and i want to copy that file to another folder using cmd- G:\work\

I use copy C:\vackwrk\24may\abc.txt G:\work\ this work , but when i am using wildcard it don't work copy C:\vackwrk\*\abc.txt G:\work\ this time output is - The filename , directory name or volume label syntax is incorrect.

Why ? Is there any alternate way to copy using wildcard ?

回答1:

There is no way to use wildcard while copying from cmd because there will be ambiguity to system if there is any other directory C:\vackwrk\foo\ and C:\vackwrk\bar\,both with a file abc.txt.

But Windows PowerShell lets you to do copy using wildcard very easily , just need to open cmd and enter start powershell.exe copy C:\vackwrk\*\abc.txt G:\work\ or simply open Windows PowerShell and enter PS C:\Windows\system32> copy C:\vackwrk\*\abc.txt G:\work\ .

It works fine , so i think Windows PowerShell is more powerful than cmd.



标签: windows cmd path