Mattyy123
Mattyy123

Reputation: 73

Trying to copy files from current directory to another with batch

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.

Upvotes: 7

Views: 52472

Answers (2)

PodTech.io
PodTech.io

Reputation: 5254

if you dont want to specify the folder, you can use this;

 xcopy /y /s ".\*" %TEMPDIR%

Upvotes: 7

foxidrive
foxidrive

Reputation: 41234

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"

Upvotes: 9

Related Questions