继续获取命令的语法不正确

时间:2021-09-30 00:37:29

Hello im having a bit of problem when trying to run this batch file

您好我在尝试运行此批处理文件时遇到了一些问题

@echo off

rem ashton scotland

rem test file

cls

if exist C:\Users\ashton\Desktop\test\

echo the directory exists

can someone please guide me as to why im getting that error message thanks

有人可以指导我为什么我得到该错误消息谢谢

2 个解决方案

#1


3  

there is no command after if condition.Try this:

if条件后没有命令。试试这个:

@echo off

rem ashton scotland

rem test file

cls

if exist "C:\Users\ashton\Desktop\test\" (

 echo the directory exists
)

or

@echo off

rem ashton scotland

rem test file

cls

if exist "C:\Users\ashton\Desktop\test\"  echo the directory exists

#2


0  

Exist maches files or folders. This see's if a folder or not.

存在maches文件或文件夹。这看是否是一个文件夹。

@Echo off
pushd %1 >nul 2>&1  
If errorlevel 0 if not errorlevel 1 Echo %~nx1 is a folder
If errorlevel 1 Echo %~nx1 is not a folder
Popd

If /i "%cmdcmdline:~0,6%"=="cmd /c" pause


pause

#1


3  

there is no command after if condition.Try this:

if条件后没有命令。试试这个:

@echo off

rem ashton scotland

rem test file

cls

if exist "C:\Users\ashton\Desktop\test\" (

 echo the directory exists
)

or

@echo off

rem ashton scotland

rem test file

cls

if exist "C:\Users\ashton\Desktop\test\"  echo the directory exists

#2


0  

Exist maches files or folders. This see's if a folder or not.

存在maches文件或文件夹。这看是否是一个文件夹。

@Echo off
pushd %1 >nul 2>&1  
If errorlevel 0 if not errorlevel 1 Echo %~nx1 is a folder
If errorlevel 1 Echo %~nx1 is not a folder
Popd

If /i "%cmdcmdline:~0,6%"=="cmd /c" pause


pause