Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
When called , %1 gets test.cmd "жжжж цццц.txt" C:\Temp\-2
into the file ~Xcopy.Tmp
along with quotes, but for xcopy
it it needs to be without quotes .
@Echo Off
If '%2==' GoTo :Eof
setlocal DisableDelayedExpansion
set "file=%~1"
setlocal EnableDelayedExpansion
echo !file!>~Xcopy.Tmp
xcopy *.txt %2\ /D /Y /Exclude:~Xcopy.Tmp
If Not %ErrorLevel%==0 (
Echo Ошибка при копировании
Pause
GoTo :Eof
)
del ~Xcopy.Tmp
DIR /B %1 > ~Xcopy.Tmp
%CD%\~Xcopy.Tmp
.Overwriting all files is wrong.
EXCLUDE accepts a file with a list of files. It is necessary either to output the received name to a file and use it already.
Or you need to iterate over all files and check the file name before copying
for %%f in (path\*.txt) do (
If not %%f==%1 xcopy %%f %2\ /D /Y
If Not %ErrorLevel% ==0 (
Echo Error while copying
Pause
GoTo :Eof
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question