Batch For /R Results to be set menu choice - arrays

need a bit of help with a project.
Scenario :-
Manually migrating PC's to new Domain breaks a piece of software due to the new profile not having the settings from the old user profile - required to make it run. The old profile is called one thing, the new one - something else e.g.
C:\Users\Sue.Barnes.B3209 (old) C:\Users\Susan.Barnes.NGP (new)
Within the %localappdata% of each (old) profile there "maybe" a config file for this software, if the user has used it previously. E.g.
C:\Users\Sue.Barnes.B3209\AppData\Local\Acme_Limited\Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh\1.0.0.15\user.config
Objectives :-
I want to be able to scan through the C:\Users Folder and report back the full path, name & extension of file where it is found, then have the list set in a menu choice where upon input choice will copy the user.config file to the exact same location but in the currently logged on new profile appdata folder.
e.g.
Enumerating List Of User Profiles in the System...
Admin
Public
User
From the Profiles detecting active Configs...
C:\Users\Admin\AppData\Local\Acme_Limited\Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh\1.0.0.15\user.config
C:\Users\Public\AppData\Local\Acme_Limited\Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh\1.0.0.15\user.config
Press any key to continue . . .
However it is at this point I'm out of my depth. I cant seem to be able to create a choices menu of each instance where the file is found. However many are found, I'd like a number to be printed on the screen so I can choose the correct config to copy to the newly set up profile. Simply,
Xcopy /f C:\Users\Sue.Barnes.B3209\AppData\Local\Acme_Limited\Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh\1.0.0.15\user.config
%localappdata%\Acme_Limited\Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh\1.0.0.15\
Current code base :-
echo.
echo Enumerating List Of User Profiles in the System...
echo.
TIMEOUT /T 3 >NUL
dir /b C:\Users
echo.
echo From the Profiles detecting active Configs...
echo.
TIMEOUT /T 3 >NUL
for /R "C:\Users" %%a in (1.0.0.15\user.config*) do (
echo %%~dpnxa
)
)
echo.
pause
Any help be greatly appreciated, thanks

#ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
set "dontshow=u:\dontshow.txt"
set "configs=u:\configs.txt"
set "profiles=u:\profiles.txt"
:again
echo :>>"%dontshow%"
del "%configs%" >nul 2>nul
del "%profiles%" >nul 2>nul
:: Find all of the "user.config" files having ..\appdata\local\Acme_limited\...1.0.0.15
FOR /f "tokens=1-9delims=\" %%a IN (
'dir /s /b /a-d "%sourcedir%\user.config" '
) DO if /i "%%d"=="appdata" if /i "%%e"=="local" if /i "%%f"=="Acme_Limited" if /i "%%h"=="1.0.0.15" (
rem these are the users' config files that may be copied.
echo %%c|findstr /x /g:"%dontshow%" /i /L >nul
if errorlevel 1 >>"%configs%" echo %%c
)
:: Find all of the user profiles that are not in "dontshow" and do NOT have "user.config" - These are the profiles that may need to be processed
FOR /f "delims=" %%a IN (
'dir /b /ad "%sourcedir%" '
) DO (
echo %%a|findstr /x /g:"%dontshow%" /i /L >nul
if errorlevel 1 echo %%a|findstr /x /g:"%configs%" /i /L >nul
if errorlevel 1 >>"%profiles%" echo %%a
)
:: Now we have a list of profiles with "user.config" missing in %profiles%
:: And possible source-profiles in %configs%
:: Show the list of "config missing" profiles
cls
findstr /n /v /L /c:":" "%profiles%"
:reselectd
set "selectiond="
set /p "selectiond=Choose destination profile "
if not defined selectiond goto :eof
for /f "tokens=1*delims=:" %%a in ('findstr /n /v /L /c:":" "%profiles%"') do if "%%a"=="%selectiond%" set "selectiond=%%b"&goto selects
echo Invalid selection
goto reselectd
:selects
for /L %%a in (1,1,4) do echo.
findstr /n /v /L /c:":" "%configs%"
:reselects
set "selections="
set /p "selections=Choose source profile "
if not defined selections goto :eof
for /f "tokens=1*delims=:" %%a in ('findstr /n /v /L /c:":" "%configs%"') do if "%%a"=="%selections%" set "selections=%%b"&goto process
echo Invalid selection
goto reselects
:process
echo Copy from profile "%selections%" to "%selectiond%" ?
choice
if errorlevel 2 goto again
:: Do the copy... just echoed, remove `echo` keyword to activate
ECHO md "%sourcedir%\%selectiond%\appdata\localAcme_Limited\whatever\1.0.0.15"
ECHO copy "%sourcedir%\%selections%\appdata\localAcme_Limited\whatever\1.0.0.15\user.config" "%sourcedir%\%selectiond%\appdata\localAcme_Limited\whatever\1.0.0.15"
choice /M "Add '%selections%' to processed file ? "
if errorlevel 2 goto processedd
>>"%dontshow%" echo %selections%
:processedd
choice /M "Add '%selectiond%' to processed file ? "
if errorlevel 2 goto again
>>"%dontshow%" echo %selectiond%
goto again
Interesting exercise. Lack of information about what Acme.exe_Url_m5l4ujc5t22f3qw0q5uz1dwlfcnrdaoh is about (constant string, change-per-user? What?), though - left as an exercise for OP to resolve.
You would need to change the setting of sourcedir to suit your circumstances. The listing uses a setting that suits my system.
I decided that the key part is the third directory level - the user-id. This approach uses files of user-id, two are temporary and one is permanent - "dontshow.txt" which contains a list of user-ids NOT to show. This can be manually maintained using an editor if required.
So - to start, add a line containing a single colon to the "dontshow" file. This is a dummy which can never match a real user-id and is required because findstr doesn't like an empty dictionary file.
The first step is to find all of the user.config files, and use for /f to process the filenames found, selecting the significant directory-levels. Having excluded any path that does not fit the criteria, the third level contents is matched against the exclusions in "dontshow.txt". If the name found is new, add it to the configs file.
Second verse - same as the first, but this time only looking at the directory names. Note that the entry is made to profiles if the name found is NOT on the dontshow list AND is also NOT on the config list.
Now select a destination profile by listing profiles and appending a prefix linenumber: using findstr. Enter a number (manual entry, unchecked) and then match the line number by using for/f.
Rinse and repeat for the configs file for the source profile.
Display the proposed command, accept a Y/N response then ask whether each name should be added to the dontshow list.
And straight on 'til morning.
Note that responding with Return to any of the set /p commands will exit the batch.

Related

List Directory and number of files with specific extension, build a specific menu

I am trying to create a menu with submenus which their names without extension come from the directory. However, I am unable to make a variable for choice as number. This code does not work anyhow. I would also want to display a number at the beginning of each file name in the menu; in fact, number of the files will also be one of the number that user selects as input. I could not overcome the problem.
#echo off
cd C:\Users\Murray\Documents\ConfigFiles\
for /f %%A in ('dir /a-d-s-h /b *conf ^| find /v /c ""') do set count=%%A
echo File count = %count%
for %%F in ("C:\Users\Murray\Documents\ConfigFiles\*.conf") do echo %%~nxF
set choice=
set /C /N="Please choice: "
if "%choice%" == "%count%" goto SUBMENU
if NOT EXIST "C:\Users\Murray\Documents\ConfigFiles\%choice%" goto NOFILE
:SUBMENU
Echo You are here
goto end
:NOFILE
echo %choice% could not be found.
goto END
:end
Any help will be appreciated.
Here's a quick example of a method touted in the answer by on no. It will print a number to the screen followed by the names of each file matching file extension, so will allow a large number of matching files, (although the end user may have to scroll a long list). Once a file is chosen, your end user then just types its corresponding number. The code should not proceed beyond the input request until a number matching one in the list is ENTERed.
#Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "src=C:\Users\Murray\Documents\ConfigFiles"
Set "ext=.config"
If Not Exist "%src%\*%ext%" Echo No file matches.& GoTo End
For /F "Delims==" %%G In ('"(Set #) 2>NUL"') Do Set "%%G="
For /F "Delims==" %%G In ('%SystemRoot%\System32\wbem\WMIC.exe OS Call /? ^|
%SystemRoot%\System32\find.exe "=="') Do Set "HT=%%G"
For /F "Tokens=1* Delims=:" %%G In ('Dir /B /A:-D "%src%\*%ext%" 2^>NUL ^|
%SystemRoot%\System32\findstr.exe /E /I /L /N "%ext%"'
) Do Set "#%%G=%%H" & Echo( %%G.%HT:~-1%%%H
If Not Defined #1 Echo No file matches.& GoTo End
:Opt
Echo(
Set "HT=" & Set "opt="
Set /P "opt=Enter the number for your chosen file>"
If Not Defined opt (GoTo Opt) Else Set "opt=%opt:"=%"
Set # | %SystemRoot%\System32\findstr.exe /B /L "#%opt%=" 1>NUL || GoTo Opt
SetLocal EnableDelayedExpansion
For %%G In ("!#%opt%!") Do EndLocal & Set "opt=%%~G"
#Rem Your code goes below here
Echo(& Echo You Selected %opt%
#Rem Your code ends above here
:End
Setlocal EnableDelayedExpansion & For /F "Tokens=1,2" %%G In ("!CMDCMDLINE!"
) Do Endlocal & If /I "%%~nG" == "cmd" If /I "%%~H" == "/c" Echo(& Echo Press^
any key to exit.&Pause 1>NUL
All you need to do is to modify the variables values on lines 4 and 5, if necessary, in order to test it. I will not be supporting changes or additions beyond that. Once you have tested the code, you may insert your code between lines 25 and 29, replacing the example line I left there for your test.
Batch's limitations are to blame for sub-par corrections to this question.
Here's the best I could whip up in a few seconds:
#echo off
:one
cls
cd C:\Users\Murray\Documents\ConfigFiles\
for %%F in ("C:\Users\Murray\Documents\ConfigFiles\*.conf") do echo %%~nxF
echo.
echo Enter Configuration Name:
set/p "prompt=>"
if exist %prompt%.txt goto :two
if exist %prompt% goto :two
cls
echo File not found
pause >NUL
goto :one
:two
cls
REM When file is found, this code will run
pause >NUL
The set command does not prompt for user input unless specified with the /p switch. To make your code more friendly, i'd also recommend to prompt for the filepath earlier on in the code.
EDIT: A few alternative solutions: Declare the 9th option of the prompt of the choice command as a "second page" or "more" option. This would really be a pain for the user in a directory with tens or hundreds of files. Another; you can assign an integer to each file that matches your quasi-query and echo them before each filename on the screen, then allow the user to input the number to get that file. That seems fairly efficient, and if you'd like to explore one or both of those alternates I can help (if you need it).

How to get to users %APPDATA% when running as system user from a batch file

Deploying applications via SCCM. Currently trying to deploy Wireshark and I am 1st trying to create the directory then copy over a preference file to the users %APPDATA%. The preference file basically stops the application from checking for auto updates.
Reason I need to create the directory is because it does not exist until Wireshark is launched for the 1st time.
Issue is that when doing this, SCCM is deploying as a system user so %APPDATA% goes to directory C:\Windows\System32\config\systemprofile\AppData\Roaming\
But I would like to get to C:\Users\SPECIFIC USER\AppData\Roaming
I am deploying the application with a batch file:
Wireshark-win64-2.4.6.exe /S
mkdir %APPDATA%\Wireshark\
xcopy preferences %APPDATA%\Wireshark
This will work locally on my own machine but if I run under PSEXEC (like SCCM would) then it will end up in the incorrect directory.
I am new to creating applications within SCCM as well as using batch files to deploy so please include details if possible. Regardless I appreciate the help!
Done with using getprofiles.cmd to echo the profiles and using main.cmd
with a for loop to process the profile paths.
main.cmd:
#echo off
setlocal
:: Install Wireshark.
echo Wireshark-win64-2.4.6.exe /S
:: Update Wireshark app data in user profiles.
for /f "tokens=*" %%A in ('getprofiles.cmd "\AppData\Roaming"') do (
call :skip_profile "%%~A" "\\Administrator\\" "\\MSSQL\$SQLEXPRESS\\" || (
echo mkdir "%%~A\Wireshark\"
echo xcopy preferences "%%~A\Wireshark"
)
)
exit /b
:skip_profile
for %%A in (%*) do (
if not "%%~A" == "" if /i not "%%~A" == "%~1" (
echo "%~1"| findstr /i "%%~A" >nul 2>nul
if not errorlevel 1 (
echo Skip account "%~1"
exit /b 0
)
)
)
exit /b 1
getprofiles.cmd:
#echo off
setlocal
if "%~1" == "/?" goto :help
:: ProfileList key that contains profile paths.
set "ProfileListKey=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
:: Get profiles directory path.
set "ProfilesDirectory="
for /f "tokens=1,3" %%A in (
'reg query "%ProfileListKey%" /v "ProfilesDirectory"'
) do if /i "%%~A" == "ProfilesDirectory" call set "ProfilesDirectory=%%~B"
if not defined ProfilesDirectory (
>&2 echo ProfilesDirectory is undefined
exit /b 1
)
:: Search all profile paths in profiles directory and echo existing paths appended with the 1st script argument.
for /f "delims=" %%A in (
'reg query "%ProfileListKey%"'
) do call :ProfilePath "%%~A" "%~1"
exit /b
:ProfilePath
setlocal
set "arg1=%~1"
:: Validate 1st call argument is a profile subkey.
if not defined arg1 exit /b 1
if /i "%arg1%" == "%ProfileListKey%" exit /b 1
if "%arg1:~,1%" == " " exit /b 1
:: Echo existing profile paths with defined 2nd argument appended.
for /f "tokens=1,3" %%A in (
'reg query "%arg1%" /v ProfileImagePath^|find /i "%ProfilesDirectory%"'
) do (
if "%%~A" == "ProfileImagePath" (
if exist "%%~B%~2" echo "%%~B%~2"
)
)
exit /b
:help
echo Prints profile paths from the registry that exist in the Profiles Directory.
echo 1st argument can be a path to be appended to the profile path.
echo i.e. "\AppData\Roaming" is appended to become "C:\Users\...\AppData\Roaming".
exit /b
The script main.cmd echoes the results for testing. Remove the echoes
to actually use if commands are valid.
The ProfileList key in the registry stores the path to find the
profiles and has subkeys with data such as path of each profile on
the machine.
main.cmd can avoid profiles such as Administrator and MSSQL$SQLEXPRESS.
The called label :skip_profile takes the profile path as 1st argument.
Following arguments are for patterns and if matched, will be a skipped
profile.
findstr is being used for checking the profile path for a match with
regular expressions so use findstr /? for syntax requirements.
Case is set as insensitive as to use of /i.
The getprofiles.cmd script gets the ProfilesDirectory path which
is where the user profile folders can be found. It then querys the key
to get the profile keys by using the called label of :ProfilePath.
The label checks if the ProfilesDirectory path is found in each
profile path found. It then checks if the path exists before echoing
the path. If the optional 1st parameter is passed, then it will be
appended and the path will be validated as that path.
A test outputs:
Wireshark-win64-2.4.6.exe /S
mkdir "C:\Users\Michael\AppData\Roaming\Wireshark\"
xcopy preferences "C:\Users\Michael\AppData\Roaming\Wireshark"
which seems OK as I only have 1 user profile on my current machine.
You could probably merge the code together to make just 1 script though
I decided to leave getprofiles.cmd as reusable for other uses.
Here's a batch file that may help you. It creates the directory you tell it in all user's %APPDATA% directories it finds if you don't specify a username, or creates the directory in only the specific user's %APPDATA% directory if you do specify a username.
#ECHO OFF
SETLOCAL
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
SET BAT=%~NX0
SET ROOTDIR=C:\Users
IF "%~1" == "" (
GOTO USAGE
)
SET "DIR=%~1"
SET "USER=%~2"
IF NOT "%USER%" == "" (
IF EXIST %ROOTDIR%\%USER%\AppData\Roaming\ (
IF NOT EXIST "%ROOTDIR%\%USER%\AppData\Roaming\%DIR%" (
MKDIR "%ROOTDIR%\%USER%\AppData\Roaming\%DIR%"
ECHO Created %ROOTDIR%\%USER%\AppData\Roaming\%DIR%
)
)
GOTO :EOF
)
FOR /F "DELIMS=" %%D IN ('DIR /A:D /B %ROOTDIR%') DO (
IF EXIST %ROOTDIR%\%%D\AppData\Roaming\ (
IF NOT EXIST "%ROOTDIR%\%%D\AppData\Roaming\%DIR%" (
MKDIR "%ROOTDIR%\%%D\AppData\Roaming\%DIR%"
ECHO Created %ROOTDIR%\%%D\AppData\Roaming\%DIR%
)
)
)
GOTO :EOF
:: --------------------------------------------------------------------------
:USAGE
ECHO.
ECHO A batch file that creates a directory in every user's %%APPDATA%% directory
ECHO if no username is specified or creates the directory only for the specific
ECHO user if the username is specified.
ECHO.
ECHO Usage: %BAT% ^<directory^> [username]
GOTO :EOF
Find the owner of the EXPLORER.EXE process:
for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" (set domain_user=%%c)
for /f "TOKENS=1,2 DELIMS=\" %%a in ("%domain_user%") do set domain=%%a && set LoggedInUserID=%%b
 
for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" (set domain_user=%%c)
for /f "TOKENS=1,2 DELIMS=" %%a in ("%domain_user%") do set domain=%%a && set LoggedInUserID=%%b

Find multiple files' paths with the same file name

I tried to write a batch script that find all the paths of files that have the same name as the input string. right now it can find only the first file found, and i cant think of a way to make it list multiple files locations. I am not very experienced and I need some help.
this is part of the script code:
:start
cls
echo Enter file name with extension:
set /p filename=
echo Searching...
for %%a in (C D E F G H U W) do (
for /f "tokens=*" %%b in ('dir /s /b "%%a:\%filename%"') do (
set file=%%~nxb
set folderpath=%%~dpb\
::the path of the file without the filename included "C:\folder\folder\"
set fullpath=%%b
::the path of the file with the filename included "C:\folder\folder\file"
goto break
)
)
:notfound
cls
echo Enter file name with extension:
echo %filename%
echo File Not Found!
ping localhost -n 4 >nul
goto start
:break
if "%folderpath:~-1%"=="\" set folderpath=%folderpath:~,-1%
cls
echo ? %filename% found
echo %fullpath1%
echo %fullpath2%
echo %fullpath3%
--- || ---
I want the script to search the computer and list every encountered files with the same name and I want to be able to put those files' paths into different variables.
For example, if readme.txt is the input, then I want the list of all the paths of all the files with that specific name (readme.txt) and I want to set variable for each path so I can use it after that.
example:
input:
readme.txt
output:
3 files found
C:\folder\folder\readme.txt
C:\folder\folder\folder\readme.txt
D:\folder\readme.txt
variables:
path1 = C:\folder\folder\readme.txt
path2 = C:\folder\folder\folder\readme.txt
path3 = D:\folder\readme.txt
Here is a single script which will performs the task requested. It searches all drives for your input filename with extension, puts each found full file path into a variable, then output those variables for you. I will not be tailoring the script for any new changes after this response, advising on how to integrate it into the rest of your script or supporting any changes you may subsequently make.
#Echo Off
Set/P "SearchTerm=Enter file name with extension: "
Set "i=0"
For /F "Skip=1" %%A In ('WMIC LogicalDisk Where^
"DriveType>1 And DriveType!=5 And FreeSpace Is Not Null" Get DeviceID'
) Do For %%B In (%%A) Do (For /F "Delims=" %%C In (
'Where/F /R %%B\ "%SearchTerm%"2^>Nul') Do (Set/A i+=1
Call Set FullPath[%%i%%]=%%C))
If %i% LSS 1 (Echo= %SearchTerm% Not Found) Else (
Echo= %SearchTerm% had %i% match(es^)
For /L %%A In (1,1,%i%) Do (
Call Echo= %%%%FullPath[%%A]%%%% = %%FullPath[%%A]%%))
Timeout -1 1>Nul
Please be warned that searching many locations and putting many files into variables may over burden your system and cause issues.

Search for substring in folder names

I hope someone can help me with my problem.
There is a directory containing folders for every order, e.g.
L:\Med_Department\Orders\
L:\Med_Department\Orders\T0012345_AB100_CustomerA_site2
L:\Med_Department\Orders\T0012346_CD350-CustomerB site1
...
How can I get the full name of a folder by searching for the order number.
When I enter the order number for example:
T0012345
,
I want the script to store
T0012345_AB100_CustomerA_site2
in a variable so I can use it to create the folder for my new project instead of the order number.
The order number is unique and has the format Txxxxxxx . The rest of the folder name can be separated by underscore, blank space or other characters.
If the order number is not found (e.g. order number not entered correctly) the user should enter the order number again.
This is what I achieved so far.
I enter the order number and the script copies a template folder into my projects directory with the order number as folder name.
#Echo off
rem directories
set template= "N:\Documentation\New_folder_OrderNo-Type-Customer-site"
set dirOrder= "L:\Med_Department\Orders\"
SET dirProjects= "Z:\Projects\2016\"
rem input Order No.
echo Please enter the order number?
echo.
set /p OrderNo=OrderNo:
rem target directory
set dirNewProject=%dirProjects%%OrderNo%\
echo %dirnewProject%
pause
rem copy content from template into target directory
xcopy %template% %dirNewProject% /S /E /C /H /O /R /Y /D /V
rem open target directory
explorer %dirNewProject%
;exit
Thanks in advance.
something like this:
#Echo off
rem directories
set template= "N:\Documentation\New_folder_OrderNo-Type-Customer-site"
set dirOrder = "L:\Med_Department\Orders\"
SET dirProjects= "Z:\Projects\2016\"
:again
rem input Order No.
echo Please enter the order number?
echo.
set /p OrderNo=OrderNo:
if not exist "%dirOrder%%OrderNo%\" (
echo order %OrderNo% not found
goto :again
)
:: the rest of the script
:: ...
?
use a for to get the output of a command. Use dir with proper switches to do a wildcard search (Note: with dir wildcards do only work within the very last element of a path).
:again
set /p "OrderNo=OrderNo: "
set "folder=none"
for /f "delims=" %%a in ('dir /s /ad /b %dirOrder%%OrderNo%*') do set folder=%%a
if %folder% == none goto :again
echo found: %folder%
see for /? and dir /? for details
You can simply use for /D against the pattern %OrderNo%*. If there is folder whose name starts with %OrderNo% (there should be one only, if I got it right), dirNewProject is going to hold its path; if there is none, the variable is going to be empty. You can chek if [not] defined dirNewProject afterwards and jump to a :LABEL contitionally:
rem (skipping data entry part of script)
rem directory
set "dirNewProject="
for /D %%I in ("%dirProjects%\%OrderNo%*") do set "dirNewProject=%%I"
if not defined dirNewProject goto :LABEL
rem (skipping file copy part of script)
Example...(Untested)
#Echo Off
SetLocal
Rem directories
(Set template=N:\Documentation\New_folder_OrderNo-Type-Customer-site)
(Set dirOrder=L:\Med_Department\Orders)
(Set dirProjects=Z:\Projects\2016)
Rem exit if above directories do not exist
For %%a In (template dirOrder dirProjects) Do (If Not Exist "%%%%a%%\" Exit/B)
Rem make search dir current
If /I Not "%CD%" Equ "%dirOrder%" PushD %dirOrder%
:AskNum
Rem input Order No.
Echo(
Echo( Please enter the order number?
Echo(
Set/P "OrderNo=OrderNo: "
For /D %%a In ("%OrderNo%*") Do (Set OrderDir=%%~a)
If Not Defined OrderDir (Choice /C /M "Would you like to try again?"
If Errorlevel 2 Exit/B
GoTo :AskNum)
Rem new project directory
(Set dirNewProject=%dirProjects%\%OrderDir%)
Rem copy content from template to new project directory
If Not Exist "%dirNewProject%\" (
RoboCopy "%template%" "%dirNewProject%" /E /Copy:DATSO)
Rem open new project directory
Explorer "%dirNewProject%"

DIR /p pausing not working...?

I am having a problem. I need my code to list all the text files in a big directory and pause at each full screen. I set it up so that users will be able to input the number that is listed beside every txt file in the list but the /p parameter refuses to pause the list...
DIR SAVES\*.txt /B /P |FIND /V /N "//"
ECHO.
ECHO (Press "Q" to EXIT to the main menu)
ECHO.
CHOICE /C DLVQ /N /M "Would you like to DELETE, LOAD, or VIEW a file [D/L/V]?"
IF ERRORLEVEL 4 GOTO MENU
IF ERRORLEVEL 3 GOTO VIEW
IF ERRORLEVEL 2 GOTO LOAD1
IF ERRORLEVEL 1 GOTO DELETE
:DELETE
ECHO.
SET /P C=Choose the file number [#] to DELETE (and press ENTER):
FOR /F "usebackq tokens=1,2* delims=[]" %%d IN (`DIR SAVES\*.txt /B ^|FIND /V /N "//"`) DO (
IF /I !C! EQU q (GOTO MENU)
IF !C! EQU %%d (
ECHO.
CHOICE /N /M "Are you sure you want to DELETE %%e [Y/N]?"
IF ERRORLEVEL 2 GOTO LOAD
DEL /Q "SAVES\%%e"
DEL /Q "SAVES\"%%~ne"_stats"
IF EXIST "SAVES\%%e" (
IF EXIST "SAVES\"%%~ne"_stats" (
GOTO DELETE1
The folder could potentially have hundreds of txt save files and i need the ability to run this script in its own cmd window and pause as the screen fills up with info. Running my whole utility as a .bat means there is NO scrollbar available for users to view all the files. How can I make the /P pause parameter work?
You're piping the output of dir to find. find itself doesn't do pagination and simply outputs anything it matches in the input. dir itself can't do the pagination in this case, because find would be unable to do the input to advance to the next page, so you've effectively disabled pagination.
Try
dir | find | more

Resources