如何在 DOS 批处理中清空键盘缓冲区?
我制作了一个简单的批处理脚本来生成 CodeIgniter 文件夹结构(脚手架),但是...该脚本会记住 %1 环境变量的最后一个值,因为有一个键盘缓冲区。有什么简单的解决办法吗?我使用的是 Windows 7
@echo off
REM by Pablo Bozzolo (2011)
REM HOW to empty keyboard buffer before ???
if "%1"=="" goto inicio
set (%uname%)=(%1)
goto creacion
:inicio
set /P uname=Nombre del modulo ?
if "%uname%"=="" goto inicio
echo Desea crear el modulo %uname%
choice
if errorlevel 2 goto end
:creacion
mkdir %uname%
cd %uname%
mkdir config
mkdir controller
mkdir libraries
mkdir models
mkdir views
type NUL > ./controller/%uname%.php
type NUL > ./models/%uname%_m.php
cd..
echo Modulo %uname% creado!
goto end
:end
I've made a simple batch script to generate CodeIgniter folder structure (scaffolding) but... the script remembers the last value of the %1 enviroment variable because there is a keyboard buffer. Any simple solution? I'm using Windows 7
@echo off
REM by Pablo Bozzolo (2011)
REM HOW to empty keyboard buffer before ???
if "%1"=="" goto inicio
set (%uname%)=(%1)
goto creacion
:inicio
set /P uname=Nombre del modulo ?
if "%uname%"=="" goto inicio
echo Desea crear el modulo %uname%
choice
if errorlevel 2 goto end
:creacion
mkdir %uname%
cd %uname%
mkdir config
mkdir controller
mkdir libraries
mkdir models
mkdir views
type NUL > ./controller/%uname%.php
type NUL > ./models/%uname%_m.php
cd..
echo Modulo %uname% creado!
goto end
:end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想处理%1(如果它是空的),只需写
If you would like to handle %1 if its empty, simply write