Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 



Sign in to follow this  
gendouhydeist

Want to find a folder through DOS

Recommended Posts

ok what i need to do is to find a certain folder in all drives so that I could set it as variable... like

set INSTALL=D:\Installer

but I don't know how to find it or set it, if that Folder does not exist on that drive..., just for curiosity also to install apps easily...

Share this post


Link to post
Share on other sites

Yzöwl    30
@ECHO OFF & SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
FOR /F "TOKENS=1" %%# IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (
IF EXIST %%#INSTALLER SET "INSTALL=%%#Installer")
IF NOT DEFINED INSTALL GOTO :EOF
:: REST OF CODE BELOW HERE
::EXAMPLE COMMAND USING %INSTALL% VARIABLE
ECHO=[%INSTALL%]

Share this post


Link to post
Share on other sites
Yzöwl    30
does :EOF works without using exit command for it??

Yes!

what "TOKENS=1" stands for??

TBH, it's not needed, I just failed to remove it from the code I copy/pasted it off!

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
FOR /F %%# IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (
IF EXIST %%#INSTALLER SET "INSTALL=%%#Installer")
IF NOT DEFINED INSTALL GOTO :EOF
:: REST OF CODE BELOW HERE
::EXAMPLE COMMAND USING %INSTALL% VARIABLE
ECHO=[%INSTALL%]

Share this post


Link to post
Share on other sites
jaclaz    910

For the record, this is Windows 7 "Batch language" or "Command interpreter" or "Command line" or "Command console", NOT DOS.

jaclaz

Share this post


Link to post
Share on other sites

Here is how you would do it using VBS scripting.


Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Drv, Loc
'-> Search All Drives For Installer Folder
For Each Drv In Fso.Drives
If Fso.FolderExists(Drv & "\Installer") Then Loc = Drv & "\Installer"
Next
'-> Check The Resuts Of Searching The Drives
If Len(Loc) > 2 Then
MsgBox Loc,4128,"Confirm Folder"
Else
MsgBox "Can Not Find The Installer Folder",4128,"Missing Folder"
End If

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×