0

I have created a batch file that copies pdf files in different server. The file name of the folder destination of files in desktop must be like this '2 Backup (name of user)'.

So, I want the user input their name once and make the inputted name the default value of /p variable. (kinda like remember this when inputting password in a login form)

set /p name=Input your name:

so that when I xcopy files it would look like this :

xcopy "%setPath%\08_AUG\%day_month%\%code%\%code%sample.pdf" "%HOMEPATH%\Desktop\2 Backup %name%\%code%\" /D /E /C /I /Y /H

can someone help?

Gelxxxx
  • 161
  • 1
  • 17
  • What is the problem, have you tried the command? Does the destination folder already exist? –  Aug 22 '19 at 05:00
  • there is no problem in my sample command it works, and the folder exist or not exist it will create a folder in desktop automatically. What I want is the user must be input their name once.. so that they don't have to enter their name each time they will open the batch file.. – Gelxxxx Aug 22 '19 at 05:10
  • can you make the specific code? – Gelxxxx Aug 22 '19 at 05:35

1 Answers1

0

Replace your set /p with this snippet to set name locally and persistent.

if not defined name (
    set /p "name=Input name for 2 Backup:"
    call setx name "%%name%%"
)

Without knowing your batch delayedexpansion state using a pseudo call instead.