Below is a batch script that I have put together which copies the content of another folder and pastes it into a new folder that it creates called IC_Transfer.
@echo off
@break off
@title IC Transfer
setlocal EnableDelayedExpansion
if not exist "C:\Temp\IC_Transfer" (
md "C:\Temp\IC_Transfer"
ROBOCOPY /-y "Q:\Work\Temp\Dan" "C:\Temp\IC_Transfer" /mir
if "!errorlevel!" EQU "0" (
echo Transfer Successful! )
) else (
if exist "C:\Temp\IC_Transfer" (
echo Error Transferring File
echo File Already Exists
:Choice
set /P c=Would You Like To Overwrite[Y/N]?
if /I "%c%" EQU "Y" goto Overwrite
if /I "%c%" EQU "N" goto Stop
) )
:Overwrite
md "C:\Temp\IC_Transfer"
ROBOCOPY "Q:\Work\Temp\Dan" "C:\Temp\IC_Transfer" /mir
if "!errorlevel!" EQU "0" (
echo Transfer Successful )
goto End
:Stop
echo Transfer Cancelled
goto End
:End
pause
exit
pause
exit
The make directory and robocopy functions work as they should by purging the directory, re-creates it and pastes the contents. What I cannot get working is the choice command.
Regardless of whether I choose Y or N it overwrites the file contents.
I'm new to batch scripts so any help would be appreciated