0

I already have a batch file that does the backup renaming the folder adding the date:

@echo on
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set    dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%


set stamp=001_%YYYY%%MM%%DD%
mkdir %stamp%
cd %stamp%

xcopy V:\DB\001\*.* /S /Y 

Now i would like to add a text description to the folder name, chosing it between 3 or 4 different solutions, for example "001_20150309_TEXT1", or "001_20150309_TEXT2" or "001_20150309_TEXT3" Is it possible to add prompt request on what text to add? thanks in advance to all the ones who helps me out

dan1st
  • 12,568
  • 8
  • 34
  • 67
Nicola
  • 1

1 Answers1

0

You could prompt for user input like this:

SET /p choice=
IF %choice%==1 mkdir %stamp%_TEXT1 & cd %stamp%_TEXT1
IF %choice%==2 mkdir %stamp%_TEXT2 & cd %stamp%_TEXT2
IF %choice%==3 mkdir %stamp%_TEXT3 & cd %stamp%_TEXT3
IF %choice%==5 mkdir %stamp%_TEXT4 & cd %stamp%_TEXT4

Or you could use the CHOICE.EXE.

CHOICE /C 1234 /M Select text 1, 2, 3 or 4
IF errorlevel 4 mkdir %stamp%_TEXT4 & cd %stamp%_TEXT4
IF errorlevel 3 mkdir %stamp%_TEXT3 & cd %stamp%_TEXT3
IF errorlevel 2 mkdir %stamp%_TEXT2 & cd %stamp%_TEXT2
IF errorlevel 1 mkdir %stamp%_TEXT1 & cd %stamp%_TEXT1

Note the order of the errorlevel checks.

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62
Script_Coded
  • 709
  • 8
  • 21
  • Oh, that's what I thought. Could you correct me, please? – Script_Coded Mar 09 '15 at 15:05
  • Great!!! Thank you! The "SET /p choice=" did the job... is there also a way to write the choice on screen? So maybe ... wanna do this? press 1! wanna do that press 2! sorry my dos is really bad ;) – Nicola Mar 10 '15 at 11:14
  • Yes there is :) You could simpely use the `ECHO` command like this `ECHO 1) Text 1` The `ECHO` command will display text in the CMD window on a new line. If you want to add a prompt message for the choice you can do it like this `SET /p choice=Text number: ` Hope it helps :) – Script_Coded Mar 12 '15 at 21:41
  • If you think my answer did the job I'd appreciate if you marked it as correct :) Thank you – Script_Coded Mar 14 '15 at 10:50