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. 


Recommended Posts

Hello guys,

I want to create a batch file that searches the entire hard drive and then displays the requested folder/song/movie. This i got so far...

@ Echo off

@echo Please enter the name of the file or folder you want to find!

set /P=

for %%i in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do if exist %%i\ @ECHO Found in this local hard drive %%i\

if NOT exist %%i\ @Echo Folder not found!! Probably you don't have it on your hard drive!

I'm doing something wrong because when i enter the word , Atlantis for example it shows me this :

Please enter the name of the file or folder you want to find!

Atlantis

Found in this local hard drive C:\

Found in this local hard drive D:\

Found in this local hard drive E:\

Folder not found!! Probably you don't have it on your hard drive!

Any help will be great...

Regards,

Sorin

Share this post


Link to post
Share on other sites

if you have 4 drives on your computer, and this file is on C D & E but not on the 4th drive then that batch behaved normally, no?

Share this post


Link to post
Share on other sites

if you have 4 drives on your computer, and this file is on C D & E but not on the 4th drive then that batch behaved normally, no?

yes, the batch will behave normally , and it will find the file you're searching , on the drive...

BUT , the batch ain't done yet...Like i stated before , i'm doing something wrong with the search criteria . It doesn't displays the results as it should do ...

Edited by titishor

Share this post


Link to post
Share on other sites

Will this do you?

@ECHO off & SETLOCAL enableextensions disabledelayedexpansion
SET/P "TOFIND=Please enter the name of the file or folder you want to find! "
FOR /F %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO CALL :SUB %%~dA
PING -n 11 127.0.0.1 1>NUL & GOTO :EOF
:SUB
DIR/B/S/A %1\%TOFIND% 2>NUL || ECHO=%TOFIND% not found in drive %1!!

Share this post


Link to post
Share on other sites

It might be better idea to use a VBS Script or an HTA with VBS Or Js Scripting to do what you want.

Share this post


Link to post
Share on other sites

Will this do you?

@ECHO off & SETLOCAL enableextensions disabledelayedexpansion
SET/P "TOFIND=Please enter the name of the file or folder you want to find! "
FOR /F %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO CALL :SUB %%~dA
PING -n 11 127.0.0.1 1>NUL & GOTO :EOF
:SUB
DIR/B/S/A %1\%TOFIND% 2>NUL || ECHO=%TOFIND% not found in drive %1!!

Yep, it works. Thanks for the help!!!

Share this post


Link to post
Share on other sites

It might be better idea to use a VBS Script or an HTA with VBS Or Js Scripting to do what you want.

i don't know how to write it in VB:)

Edited by titishor

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...