Debajyoti Das
Debajyoti Das

Reputation: 2138

The filename, directory name, or volume label syntax is incorrect inside batch

When I am running the following inside batch....

set PATH='C:\Users\DEB\Downloads\10.1.1.0.4'
cd !PATH!

I get error "The filename, directory name, or volume label syntax is incorrect"

Update: There are the solutions that worked for me.

Upvotes: 33

Views: 324680

Answers (2)

yu yang Jian
yu yang Jian

Reputation: 7161

In my case, if I use cmd to run batch file, and the batch file path is not correct show this error, for example users>E:\TEST"E:\TEST.bat error, users>E:\TEST.bat works. after check my path it's fixed.

Upvotes: 0

TessellatingHeckler
TessellatingHeckler

Reputation: 28983

set myPATH="C:\Users\DEB\Downloads\10.1.1.0.4"
cd %myPATH%
  • The single quotes do not indicate a string, they make it starts: 'C:\ instead of C:\ so

  • %name% is the usual syntax for expanding a variable, the !name! syntax needs to be enabled using the command setlocal ENABLEDELAYEDEXPANSION first, or by running the command prompt with CMD /V:ON.

  • Don't use PATH as your name, it is a system name that contains all the locations of executable programs. If you overwrite it, random bits of your script will stop working. If you intend to change it, you need to do set PATH=%PATH%;C:\Users\DEB\Downloads\10.1.1.0.4 to keep the current PATH content, and add something to the end.

Upvotes: 23

Related Questions