Hi there,
I'm trying to make a batch file that will run a program which needs to be applied to different paths everytime. Now besides manually changing the path everything which is literally 6 numbers to edit, I was wondering if it would be possible to simply have a the command ask me that 6 digit number and apply it to me in the command line. Example:
Instead of setting the number myself
C:\Data\Hosted\Company000000\Profiles\
I would like something like this:
Enter Client Number:
C:\Data\Hosted\Company%ClientNo%\Profiles\
Is it possible to create a variable that will change a data path in a command?
Moderator: DosItHelp
-
- Posts: 3
- Joined: 18 Jun 2020 08:37
Re: Is it possible to create a variable that will change a data path in a command?
Code: Select all
set /P "ClientNo=Enter Client Number: "
echo C:\Data\Hosted\Company%ClientNo%\Profiles\
-
- Posts: 3
- Joined: 18 Jun 2020 08:37
Re: Is it possible to create a variable that will change a data path in a command?
Works perfectly, thanks mate.Aacini wrote: ↑18 Jun 2020 11:31AntonioCode: Select all
set /P "ClientNo=Enter Client Number: " echo C:\Data\Hosted\Company%ClientNo%\Profiles\
Re: Is it possible to create a variable that will change a data path in a command?
A slightly over the top means that ensures the input is numerical and of the desired length.
Code: Select all
@Echo off
(Set \n=^^^
%= Newline Var - Do not modify =%
)
Set "Profile=C:\Data\Hosted\Company------\Profiles\"
::: [Fixed Length Input Macro]
::: Usage: %DATAENTRY% [Var Name] [Choice character options] [Input Length] [Optional: M - mask input]
Set DATAENTRY=For %%n in (1 2) Do If %%n==2 (%\n%
For /F "Tokens=1,2,3,4 Delims= " %%G in ("!INPUT!") Do (%\n%
^<Nul Set /P "=%%G: "%\n%
Set "%%G="%\n%
For /L %%# in (1 1 %%I) Do (%\n%
For /F "Delims=" %%C In ('Choice /N /C:%%H') Do (%\n%
If /I "%%J" == "M" (^<Nul Set /P "=*") Else ^<Nul Set /P "=%%C"%\n%
Set "%%G=!%%G!%%C"%\n%
)%\n%
)%\n%
)%\n%
Echo/%\n%
) Else Set INPUT=
::: [End Macro Definition]
Setlocal EnableDelayedExpansion
%DATAENTRY% ACC# 0123456789 6
Echo/%Profile:------=!ACC#!%