Explorer batch

September 15, 2009 at 08:22:24
Specs: Windows XP Pro SP3
Hi all,
I am posting here a bat that consider can be usefull to others as it is to me.It is a kind of simple explorer/file-manager. I like it because I can take the advantages of both graphical and command line environment, like filtering, large fonts... You can browse the computer and type immediate commands without have to use apps like Drop2DOS each time you want to get into a folder and use commnand line.
(My english doesn't sound that good, but the bat works despite that.)


@echo off&cls&setlocal enabledelayedexpansion&color 08
:: when answering (y/n), Enter=No
mode con lines=1200 cols=80&set func=0&set hot=%CommonProgramFiles%
set lastfile=--&set lastfd=%cd%
set pth=%cd%&set batpath=%cd%&set /a ctcd=1
echo last folders>"%temp%"\lastfd.txt
if not exist "%temp%"\initialpath.txt echo %cd%>>"%temp%"\lastfd.txt & goto :prompt
for /f "usebackq tokens=* delims=" %%a in ("%temp%\initialpath.txt") do set pth=%%a
if exist "%pth%" (
pushd "%pth%"\&echo %pth%>>"%temp%"\lastfd.txt
goto :prompt
cls&echo.&echo Choose drive letter (c,d ...) __ k = Desktop
set pth=&set /p "pth= Type: "&if "%pth%"=="" goto :prompt
if /i "%pth%"=="x" goto :prompt
if /i "%pth%"=="k" set pth="%userprofile%\desktop" & goto :bg2
if not exist "%pth%":\ (
echo.&echo Path do not exists.&pause&goto :begin
set pth="%pth%:\"
set qmd=&pushd %pth%&if not "%cd%"=="%lastfd%" call :cdcheck
if %func%==1 goto :eof&goto :listsub
if "%func%"=="1" set func=%func0%&goto :eof
cls&set qmd=&echo %cd%
echo ____________________________________________________________________
echo Shortcuts: s = subdiretories .. f = files .. r = root .. e = explore
echo .. . . . . l = last folders ... b = backup . h = HOT ... x = exit
echo ____________________________________^| rd = remove current folder ^|__
if "%func%"=="bkp" echo --- 'burn' = start backup .. 'cancel' = cancel backup ---
set /p "qmd= Your command: "
if "%qmd%"=="" goto :prompt
if /i "%qmd%"=="h" goto :hot
if /i "%qmd%"=="f" goto :listfiles
if /i "%qmd%"=="s" goto :listsub
if /i "%qmd%"=="r" goto :begin
if /i "%qmd%"=="b" goto :backup
if /i "%qmd%"=="e" set x=fold & goto :explore
if /i "%qmd%"=="l" goto :lastfd
if /i "%qmd%"=="burn" goto :burn
if "%qmd%"=="rd" goto :RemCurrDir
if /i "%qmd%"=="x" goto :end
if /i "%qmd%"=="cancel" set func=0&color 08&goto :prompt
if "%qmd%"=="=" set qmd=short&goto :listfiles
if "%qmd%"==";" set qmd=short&goto :listfiles
::the above 2 options are shortcuts
echo ____________________________________________________________
set x=pause
if "%qmd:~0,2%"=="cd" (
set x=
if "%qmd:~4,1%"==":" set qmd=!qmd:cd=pushd!
set pth=%cd%
if not "%cd%"=="%lastfd%" call :cdcheck
echo.&goto :prompt
cls&echo %cd%&echo.
set x=&set /a ct=0&set /a ct2=0
for /f "tokens=* delims=" %%a in ('dir /b /a:d') do (
set /a ct+=1&set /a ct2+=1&set folder!ct!="%%~fa"
echo !ct! - %%a
if !ct2!==21 (
set /a ct2=0
set /p "x=Number= Open .. E+Number= Explore .. Enter=Next .. X=Escape : "
set y=!x:~0,1!
if /i "!y!"=="e" set numb=!x!&goto :ms2
if /i "!x!"=="x" goto :prompt
set /a x=!x!+0
if !x! gtr !ct! echo - E R R O R&pause&goto :prompt
if !x! gtr 0 set numb=!x!&goto :ms2
if !ct! gtr 0 goto :menusub
cls&echo .&echo %cd%&echo.
if %func%==bkp (
echo - No subdirectories in this folder -&pause
call :cdcheck
goto :prompt
echo - No subdirectories in this folder - Now, going to the prompt -
echo.&pause&goto :prompt
set numb=&echo ==================================
set /p "numb=Number= Open .. E+Number= Explore .. Enter= Back to Prompt : "
if "%numb%"=="" goto :prompt
if /i "%numb%"=="x" goto prompt
set OpenThis=folder%numb%&set x=!numb:~0,1!
if /i "!x!" neq "e" goto :OpenPath
if "%func%"=="bkp" goto :menusub
set x=!numb:~1!&set OpenThis=folder%x%&cd !%OpenThis%!
cls&echo !%OpenThis%!&color 06
echo Openning folder WINDOWED ..&pause&color 08
start /max %windir%\explorer.exe !%OpenThis%!&goto :prompt
pushd "!%OpenThis%!"
if not "%cd%"=="%lastfd%" call :cdcheck
goto :listsub
cls&echo.&echo - Hot Folders -&echo.
set numb=
set /p "numb= 1 - Access hot folders .. 2 - Edit folders list .. Enter = Go back : "
if "%numb%"=="2" pushd %hot%\ & goto :hot2
if "%numb%"=="1" pushd %hot%\ & goto :hot3
goto :prompt
if exist hot.txt goto :hot2b
cls&echo Access your favorite folders, copy the path directly>HOT.txt
echo from the Adress Bar and paste it here, one per line>>HOT.txt
echo ^( don't delete this header ^)>>HOT.txt
echo ____________________________________________________>>HOT.txt
echo %userprofile%\desktop>>HOT.txt
start /max notepad.exe HOT.txt&popd&goto :hot
if not exist hot.txt goto :hot2&cls
echo HOT FOLDERS&set x=&set /a ct=0&set /a ct2=0
for /f "skip=4 tokens=* delims=" %%a in (HOT.txt) do (
set /a ct+=1&set /a ct2+=1
set folder!ct!="%%a"&echo !ct! - %%a
popd&goto :menusub
set func=bkp&cls
color 0c&set y=y
if exist "%batpath%\backup.txt" set y=n
set x=-
if %y%==n set /p "x= - Refresh older compilation - Backup.txt ? (y/n) "
if %y%==n (
if /i "%x%"=="y" echo. 2>"%batpath%\backup.txt"
if /i "%x%"=="y" echo Refreshed. & echo.
echo You must have installed CreateCD, freeware by Alex Feinman
echo to procced backup.
echo From now on, all files and folders you access may be collected
echo into a text file: backup.txt ( compilation ).
echo In a last step you will be able to change/delete the contents
echo of this file in case you want to give up some item(s).
echo.&echo Type 'burn' in the prompt when you finish adding.
echo.&pause&goto :prompt
if /i "%qmd%"=="x" goto :end
set /a tries=0&cls&set ext=
set number=&set mask=&echo %cd%
echo Last file: %lastfile%
echo _____________________________________________________________________
echo Enter = extensions summary
echo h = html/htm/mht .. t = txt/doc .. e = exe/com .. x = back to Prompt
echo b = bat/cmd ....... l = lnk/pif .. ( mask = a*, a, a*.ext, *.h*, = )
echo _____________________________________________________________________
echo.&if not "%qmd%"=="short" (
echo Launch / Edit File . . . . . . . . . . . . . +command = execute it
set /p "mask= Type a letter or enter a mask: "
) else (
set qmd=s&set mask=;
if /i "%mask%"=="x" goto :prompt
if "%mask%"=="*" set list='dir /b /a-d /p *.*' & goto :listf2
if "%mask%"=="" goto :extsumm
if "%mask:~0,1%"=="+" (
if "%func%"=="bkp" echo You can not use '+' when font color is RED.&pause&goto :listfiles
set func0=%func%&set func=1&set qmd=%mask:~1%
call :pr2
goto :listfiles
echo - %cd%&echo.
if /i "%mask%"=="h" set list='dir /b /a-d *.mht *.html *.htm' & goto :listf2
if /i "%mask%"=="t" set list='dir /b /a-d *.doc *.txt' & goto :listf2
if /i "%mask%"=="e" set list='dir /b /a-d *.com *.exe' & goto :listf2
if /i "%mask%"=="b" set list='dir /b /a-d *.cmd *.bat' & goto :listf2
if /i "%mask%"=="l" set list='dir /b /a-d *.pif *.lnk' & goto :listf2
set list='dir /b /a-d %mask%'&goto :listf2
set x=&set /a ct=0&set /a ct2=0
FOR /f "tokens=1* delims=" %%a in (%list%) do (
set /a ct+=1&set /a ct2+=1&if !ct2!==21 (
set /a ct2=0
set /p "x= File Number = Get It .. Enter = Next Files .. X - Escape :"
if "!x!"=="x" goto :listfiles
set /a x=!x!+0
if !x! gtr 0 set number=!x!&goto :gf2
set app!ct!=%%a&set burn!ct!=%%~fa&echo !ct! - %%~nxa
if !ct!==0 (
set /a tries+=1
if !tries!==1 (
set list='dir /b /a-d %mask%*'& echo Repeating search ...
goto :listf2
echo - No files found with "%mask%" menu option nor Mask.
echo.&pause&goto :listfiles
set number=
echo ===========================
set /p "number= File number: "
if /i "%number%"=="x" goto :listfiles
if "%number%"=="" goto :listfiles
set /a x=%number%
if !x!==0 goto :getfolder
if !x! gtr !ct! goto :getfolder
set RunThis=app%number%&set burnfile=burn%number%
set lastfile=!%RunThis%!
if not exist "!%RunThis%!" (
for /f "tokens=* delims=" %%a in ("%mask%") do set fu=%%~dpa
echo !fu!>"%temp%"\initialpath.txt
pushd "!fu!"
set y=%func%&set func=0
if not "%cd%"=="%lastfd%" call :cdcheck
set func=%y%&cls & echo.
color 0e&echo ** Changing to folder: !fu! & echo.
pause&color 08
echo.&echo - File: !%RunThis%!&echo.
if %func%==bkp goto :chkBurnfile
for /f "usebackq tokens=1 delims= " %%a in ('dir "!lastfile!"') do set ext=%%~xa
set x=
set /p "x= r - run .. t - edit/view .. d .. delete .. Enter - back to menu: "
if "%x%"=="" goto :listfiles
if /i "%x%"=="r" goto :runfile
if /i "%x%"=="t" goto :editfile
if /i "%x%"=="d" goto :delfile
goto :listfiles
echo.&echo Wait...&set x='&set z='
for /f "tokens=* delims=" %%a in ('dir /b /a-d *') do (
set y=%%~xa '&set comm=%%a&call :exts2
cls&echo %cd%&echo.
echo - You pressed Enter without any mask.
echo - Below, all file extensions in current folder:
echo.&echo !x!&echo.
if not !z!==' (
echo - Bellow, files without any extension: & echo.
echo !z! & echo.
echo * Hint: to list all filenames, you can type * or = or ;
echo.&pause & goto :listfiles
if not "%y%"==" '" set x=!x:%y%=!
if not "%y%"==" '" set x=!x!%y%
if "%y%"==" '" set z=!z! - !comm!
goto :eof
if !ext!.==.bat. call "!%RunThis%!"&goto :lloop
if !ext!.==.cmd. call "!%RunThis%!"&goto :lloop
start " " /max "!%RunThis%!"& goto :lloop
if !ext!.==.doc. start " " /max "!%RunThis%!" goto :lloop
start /max notepad.exe /a "!%RunThis%!" & goto :lloop
::if "%func%"=="bkp" goto :prompt
if not "%func%"=="bkp" color 06
echo Folder: %cd%
echo Openning folder WINDOWED ..&pause
if not "%func%"=="bkp" color 08
start /max %windir%\explorer.exe %cd%
goto :prompt

echo.&echo Deleting !%RunThis%!
set /p "x= ARE YOU SURE ? (y/n): "
if "%x%"=="y" (
del /q "!%RunThis%!"
set /p "x= Press Enter to check deletion."
echo Searching for file...&dir /b "!%RunThis%!"
pause & goto :listfiles
cls & echo.
echo ( Another action with the file? )
goto :listf3
cls&echo.&echo Last Accessed Folders:
echo.&set x=&set /a skp=1
if %ctcd% gtr 18 set /a skp=%ctcd%-18
set /a ct=0&set /a ct2=0
for /f "usebackq skip=%skp% tokens=* delims=" %%a in ("%temp%\lastfd.txt") do (
set /a ct+=1&set folder!ct!="%%~fa"&echo !ct! - %%a
goto :menusub
set lastfd=%cd%
echo %cd%>"%temp%\initialpath.txt"
set /a ct=0&set /a skp=1
if %ctcd% gtr 18 set /a skp=%ctcd%-18
for /f "skip=%skp% usebackq tokens=* delims=" %%a in ("%temp%\lastfd.txt") do (
echo %%a>>"%temp%\trash.txt"
set x=no
for /f "usebackq tokens=* delims=" %%a in ("%temp%\trash.txt") do if %%a==!cd! set x=yes
if !x!==no set /a ctcd+=1 & echo %cd%>>"%temp%\lastfd.txt"
if %func%==bkp goto :cdcheckBurn
goto :eof
set /a ct=0
for /f "usebackq tokens=* delims=" %%a in ("%batpath%\backup.txt") do (
if "%%a"=="%cd%" goto:prompt
cls & echo.&echo %cd%&echo.&set x=
set /p "x=Add above folder to compilation ? (y/n) "
if /i not "%x%"=="y" goto :prompt
echo %cd%>>"%batpath%"\backup.txt&goto :eof
set /a ct=0
for /f "usebackq tokens=* delims=" %%a in ("%batpath%\backup.txt") do (
if "%%a"=="!%RunThis%!" goto:listfiles
set x=
echo t = edit/view
set /p "x=Add above file to compilation ? (y/n) "
if /i "%x%"=="t" start /max notepad.exe /a "!%RunThis%!"&goto :cbR
if /i not "%x%"=="y" goto :listfiles
echo !%burnfile%!>>"%batpath%"\backup.txt
goto :listfiles
set func=0&set func0=x&set /a ct=0&cls
pushd "%batpath%"
echo Wait please...&echo.&call :getsize&echo.
echo Press any key to check the contents of your backup list.
set /p x=Change whatever you want.
start /max notepad.exe /a "%batpath%\backup.txt"
echo.&pause&echo Checking size again. Wait...&echo.
color 08&call :getsize
echo.&set x=
set /p "x= - Proceed to backup ? (y/n) "
if /i not "%x%"=="y" goto :prompt
pushd "%batpath%"&echo.
for /f "usebackq tokens=1,* delims=" %%a in ("%batpath%\backup.txt") do (
CreateCD -nostop -r:e "%%a"
echo Errorlevel: !errorlevel!
if not "!errorlevel!"=="0" set /a ct+=1 & echo Warning: Burn failed!
echo ______________________________________&echo.
if "%ct%"=="0" echo Compilation burned successfully .
if not "%ct%"=="0" echo - %ct% fail(s) in burn.. Scroll up to check.
goto :prompt

if "%cd:~3,1%"=="" goto :prompt
set lastfd=%cd%&cls&echo %cd%
echo The above folder and all its subdirectories (if exist) will de removed.
set x=
set /p "x= Are you sure? (y/n) "
if /i "%x%" neq "y" goto :prompt
set x=&set /p "x= Really ? "
if /i "%x%" neq "y" goto :prompt
rmdir /s /q "%lastfd%"
call :cdcheck
goto prompt
::---above,compilation size---
set fsize=0&set dirsize=0
for /f "tokens=*" %%a in (backup.txt) do (
echo %%a>#
set er=
call :DotInName
set name=%%a
set size=0
if "!er!"=="0" call :file
if "!er!"=="1" call :folder
pushd "%batpath%"
set /a fsize=%fsize%/1048576
set /a totsize=%fsize%+%dirsize%
echo - Compilation Size: %totsize% MB (approximately)
del #&goto :eof
find "." #>nul
set er=%errorlevel%
goto :eof
for %%g in ("%name%") do set size=%%~zg
set /a fsize=%fsize%+%size%
goto :eof
if not exist "%name%\" goto :file
pushd "%name%\"
for /f "tokens=*" %%f in ('"dir /s /-c | find "bytes" | find /v "free" | find /v "dispo""') do set result=%%f
for /f "tokens=2 delims=)" %%i in ("%result%") do set size=%%i
set size=%size:bytes=%
set size=%size: =%
set size=%size:~0,-3%
set /a size=%size%/1048
set /a dirsize=%dirsize%+%size%
goto :eof

See More: Explorer batch

Report •

September 15, 2009 at 21:47:44
what does setlocal enabledelayedexpansion do?

Report •

September 16, 2009 at 02:59:04

Report •

September 16, 2009 at 05:51:31
By the way, that site is in My Favorite Links. Its is really great.

Report •

Related Solutions

Ask Question