I want to create a batch file to copy a file from any Dir into root folder that the .bat file located on that like a USB flash drive .
My incomplete command :
xcopy /s "%userprofile%\Desktop\test.txt" "?"
What can I replace with "?" ??? Thanks guys
What you are going to need to do is use a relative path for your USB directory. The code will look like this:
This should let you enter into a prompt where you would like to copy the folder from/its name. It will name the file the same as the original and keep the original format (.txt, etc.). Let me know if this does not work for you instead of downvoting and I will work out another solution for you asap. Best of luck!
This will do exactly as you want to any and all connected USB drives.
Is exactly what you need
You should replace it with drive letter of USB drive followed by
:\
So, the real question is how to determine, which of the drives in system are USB flash drives, I guess? Here is the code:But take into account that it definitely works only for 1 removable disk. It will fail, if two devices of this type are plugged in.