Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, great site! Iv been helped a lot by this forum over the last week while putting together a batch file..this is 1 of the best batch sites iv found..of which there are many...so thanks so far
-----------------------I'v create a batch file to backup a 'user profile' folder that could exist in 4 different known locations on c:\(or it could be present in all 4 locations on c:\)
So far so good, The problem starts if the profile is located on an unknown drive or path:..im really struggling with this and indeed may be thinking the wrong way with needing 2 seperate batches
In thinking:
1)
Create a second batch file which searches all drives for instances of the 'user profile' folder, then assigns the path of each profile found to a variable
2)
2nd batch file would then edit the first batch, ie search and replace all known 'folder location data' with the new paths stored in the variables createdConstraints:
a)
Its possible the user could have saved the profile to non default location, so just changing driver letters may not be enoughso to verify a 'found user profile':
:bat2
Do all instances of file found (If found(
"\Call of Duty 4 - Modern Warfare\players\profiles\active.txt"
)
then assign 'full path' to variable
)any help would be appreciated

ok after botching some codes from around this forum I can now search all drives for a folder
Im sure this code is processing more than it needs to, how can i tweak the inner for loop
to search all drives/files(instead of only its own folder) removing the need for the outer for loop@echo off
setLocal EnableDelayedExpansionfor %%d in (C D) do (
for /f "tokens=* delims= " %%a in ('dir/s/b/a-s \"Call of Duty 4 -Modern Warfare"') do (
set var=%%~DPa
echo the path to profile directory is !var!
))
@pause

Remove the outer loop and replace the inner one with this:
for /f "tokens=* delims= " %%a in ('dir/s/b/a-s "C:\Call of Duty 4 - Modern Warfare" "D:\Call of Duty 4 - Modern Warfare"')By the way, are you sure every PC has just a C: and a D: drive? What if it had an E: drive?

Going loopy with this, basically I need a batch file to:
1)Start searching C: for folder called "players"
2)
IF Found:
search the path of the folder(as a string) for string "VirtualStore" If True assign folder path to variable + "UAC ON"
ELSE
search the folder path location for a
file called iw3mp.exe IF TRUE assign
folder path to variable + "UAC OFF"
ELSE Continue Searching Tthe Rest Of
The Drive
3)Repeat Until All available HD's have been searched D E F etc, with Found/Verified 'players folder' locations set to variablesThe code below is to check for the "VirtualStore" string in the pathname ..but it complains of wrong syntax in the FOR statment...also I would need to create variables on the fly because the number of profiles that it could be found is unknown
ECHO SEARCHING...
FOR /f "tokens=* delims= " %%a IN ('dir/s/b/a-s "\players"') DO (
echo %playersLoc% | find "VirtualStore"if errorlevel 1 goto :not-found
:found
ECHO found
goto :end:not-found
ECHO not found:end
)

The command processor doesn't like the closing bracket coming straight after a label. If you add a statement (such as type nul) between :end and ")" then it will work.
What you're doing may be easier with VBScript, but I'm not an expert in that; others on this forum are.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |