Hack Forums
[Shell] create batch file to file search - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] create batch file to file search (/showthread.php?tid=5255177)



create batch file to file search - missNasser - Apr 30, 2016

how would i make a batch file to do a file search?


* - vaxo - Apr 30, 2016

this looks like it is somewhere along the lines.
Code
@echo OFF

for /f %%F in ('dir %2\%1 /s /b') do (
    <nul (set /p msg=%%~nxF )
    for /f %%G in ('dir %3\%%~nxF /s /b') do (
        if exist %%G (
            @echo found at %%G
        )
    )
)
%1 is the user provided file mask.

%2 is the user provided directory to search first.

%3 is the user provided directory to search second.

Call from the command line to generate a report:
FindAll *.dll d:\dir1 d:\dir2 > dll_report.txt 2

reference:
http://stackoverflow.com/questions/414715/a-bat-or-wsh-script-that-can-search-for-files


* - missNasser - Apr 30, 2016

@vaxo Hi i have just tested it and its just a blank screenand i can type anything or do anything with it.


* - Hackoo - Apr 30, 2016

Hi 🤝

You can try something like that :

PHP Code

<?php 
@echo off
Title Searching files by Hackoo 2016
Mode con cols
=90 lines=3
cls 
& color 9E
echo(
Set /p "Location=Enter the folder location where do you want to serach> "
cls & echo(
echo 
You chose this location "%Location%"
echo(
Set /p "FileName=Enter the file name to looking for> "
Set Tmp=Tmp.txt
Set SearchResult
=SearchResult.txt
echo( & cls
echo(  & echo     Please Wait for moment .... Searching for "%FileName%" on "%Location%"
where /r "%Location%" "%FileName%" > %Tmp%
Cmd /U /C Type %Tmp% > %SearchResult%
Del %Tmp%
Start %SearchResult% 



* - missNasser - Apr 30, 2016

Hi hackoo can you make it list the file instead of making it write a txt like i would like it to say all files found called "anything" then a list of them and would you view delete the files and then have an option of a few of them or all files under the name "anything"


i am trying to make a file search and delete tool


I would like to make a file search and delete tool and i would like the location to be everywhere like search the whole computer


* - jahwi - May 2, 2016

Also, creating over 3 threads about the same question is frowned upon.


* - ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ - May 2, 2016

(Apr 30, 2016 07:37 PM)Hackoo Wrote:  snip

I was unaware of the "where" command! Very interesting sir!


* - DataBuster - Jan 20, 2017

(Apr 30, 2016 08:08 PM)missNasser Wrote:  Hi hackoo can you make it list the file instead of making it write a txt like i would like it to say all files found called "anything" then a list of them and would you view delete the files and then have an option of a few of them or all files under the name "anything"


i am trying to make a file search and delete tool


I would like to make a file search and delete tool and i would like the location to be everywhere like search the whole computer

Well, yes, it's possible, but please try to do that little thing by yourself.