Sunday, February 12, 2012

Batfile: Open directory in console

Whenever i download a small commandline tool, i need to open the program via the.. commandline =)

Before i copied the path of the explorer , then opened Commandline prompt via startmenu. Then paste the path, to finally end up in the path of the commanline tool, and then start testing..

This was then.. now i have a small batfile in my SendTo menu, this way i can select any file or folder and "send" it to the batfile, and commandline promt will open in that particular directory. SWEET!
@ECHO OFF
dir %1 | FIND "%~f1" > IS_DIR.res 
set isFolder=0
for /f "tokens=*" %%T in (IS_DIR.res) do set /a isFolder=isFolder+1
DEL /S /Q /F "IS_DIR.res"
CLS
IF %isFolder% == 1 (
 CMD /k cd /d "%~f1"
) ELSE (
 CMD /k cd /d "%~dp1"
)

No comments:

Post a Comment