Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 566
Mattyy123 Avatar asked May 21 '14 11:05

Mattyy123


2 Answers

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"
like image 64
foxidrive Avatar answered Oct 19 '22 10:10

foxidrive


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

 xcopy /y /s ".\*" %TEMPDIR%
like image 7
PodTech.io Avatar answered Oct 19 '22 09:10

PodTech.io