This question already has an answer here:
- Some Copy command in windows to copy from current location to specified location 1 answer
So, I have started with this:
copy | dir /s /b | find "myFile" C:\Destination
but the problem is that the destination is not visible in this command. It only sees the first part of the command up until C:\Destination.
Is there a way I can search for a file and copy it?
I have also tried this:
SET source = dir /s /b | find "myFile"
SET destination = %CD%
copy %file% %destination%
but it doesn't work.
At some point even trying to set a variable that points to the current directory (%CD%
) doesn't work.
Thanks in advance!
PS: I'm looking for a solution that would work without installing anything new on the computer, that's why I'm thinking of batch files.
I think I could do this with VBscript but I'm not sure. If anyone thinks it's a better option please post that answer too.