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"
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"
if you start your path with \
, it's an absolute, not a relative path.
Try copy "Debug\text.txt" "..\..\new"
instead
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.
It means that you have not specified the correct path. Make sure you specify correct full path of the file. .
Instead of "\Debug\text...." specify the entire path like "C:\Debug\text..."
If you are using bat for running the copy commands, your syntax should be.
bat 'copy "C:\\Program Files (x86)\\ApplicationFiles\\firstfolder\\application.yml" "C:\\Program Files (x86)\\ApplicationFiles\\secondfolder\\application.yml"'
There are two main things in this above command:
The proper command in Windows 10 for relative paths is:
copy "%~dp0%\your_file_name.extension" "%systemdrive%\Some Folder\Other Folder"
Explanation:
%~dp0%
set the current directory. No worry about drive letter or how many levels folders you have. It can be used for forward and backward folders as "%~dp0%\subfolder\your_file.ext"
or "%~dp0%\..\..\your_file.ext"
(>>> for backward, please consult this link Get the path two directories up in batch file )%systemdrive%
is as it name, the drive were the Windows system files are.To properly refer to the complete path, need to include path with drives along with folder names and file name having correct file format.
for example :
"C:\Testfolder\test.txt"
if referring in network then " \\192.168.1.225\c$\testfolder\test.txt"
It will work correctly .