Computing.Net > Forums > Programming > search all drives for 'instances of

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

search all drives for 'instances of

Reply to Message Icon

Name: tuk
Date: May 6, 2008 at 09:43:52 Pacific
OS: VISTA
CPU/Ram: Opteron 2x2Ghz and 2.5Gb
Product: custom
Comment:

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 created

Constraints:
a)
Its possible the user could have saved the profile to non default location, so just changing driver letters may not be enough

so 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



Sponsored Link
Ads by Google

Response Number 1
Name: tuk
Date: May 6, 2008 at 18:07:40 Pacific
Reply:

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 EnableDelayedExpansion

for %%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


0

Response Number 2
Name: klint
Date: May 7, 2008 at 07:21:31 Pacific
Reply:

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?


0

Response Number 3
Name: tuk
Date: May 9, 2008 at 11:07:37 Pacific
Reply:

IGNORE


0

Response Number 4
Name: tuk
Date: May 9, 2008 at 13:34:18 Pacific
Reply:

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 variables

The 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


)


0

Response Number 5
Name: tuk
Date: May 10, 2008 at 13:33:14 Pacific
Reply:

humpty bumpty


0

Related Posts

See More



Response Number 6
Name: klint
Date: May 12, 2008 at 01:54:53 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: search all drives for 'instances of

Batch to search all drives and copy newest www.computing.net/answers/programming/batch-to-search-all-drives-and-copy-newest/20316.html

batch: read vars from .txt___search www.computing.net/answers/programming/batch-read-vars-from-txtsearch/16494.html

batch file to search all drives www.computing.net/answers/programming/batch-file-to-search-all-drives/17464.html