Trying to copy files from current directory to another with batch

batch-file, windows

Solution

If you use relative paths, this will copy the file from "Internal Folder" which resides in the current directory.

xcopy "Internal Folder\abc.txt" "C:\Users\Matthew"

In Linux the syntax is `./foldername` but in Windows the `.` is implied, which means current directory, but you can add it too as shown here:

xcopy ".\Internal Folder\abc.txt" "C:\Users\Matthew"

Problem

I have a folder on my desktop called 'Folder' and inside this folder, there is another folder called 'Internal Folder'. Inside 'Internal Folder' there is a file called 'abc.txt', and inside 'Folder', I have a batch file to copy the contents of 'Internal Folder' to another destination on the computer. Now, I assumed that because you can run a file using `start /d "\" file.exe` ("\" being the directory that the batch file is housed) that I could use xcopy in a like fashion.. `xcopy "\Internal Folder\abc.txt" "C:\Users\Matthew"` (As an example.) So my question is, what command can I use to copy over a file from a folder that can be moved around to different places on the hard drive, to a static directory? Thanks in advance.

Original source