Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch - copy file using relative path

I'm a beginner with batch. I would like to copy file in \Debug\test.ext into ..\..\new by batch command.

I tried copy "\Debug\text.txt" "..\..\new", but get error "the system cannot find the file specified"

like image 292
Dan Avatar asked Sep 10 '13 05:09

Dan


People also ask

How do I duplicate files using the command line?

Highlight the files you want to copy. Press the keyboard shortcut Command + C . Move to the location you want to move the files and press Command + V to copy the files.


2 Answers

if you start your path with \, it's an absolute, not a relative path. Try copy "Debug\text.txt" "..\..\new" instead

like image 96
Stephan Avatar answered Sep 22 '22 16:09

Stephan


if you have Debug subdir try with

md   "..\..\new" >nul 2>&1 copy ".\Debug\text.txt" "..\..\new" 

md will create a new directory two levels up if you don't have it already.

like image 33
npocmaka Avatar answered Sep 19 '22 16:09

npocmaka