Home > OS >  how do i rename a folder without getting the error "The filename, directory name, or volume lab
how do i rename a folder without getting the error "The filename, directory name, or volume lab

Time:01-31

So basically im trying to making a batch script which renames the directory "C:\Program Files (x86)\Steam\steamapps\common\SteamVR" to "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa" it switches to SteamVR when enabled and SteamVRa when disabled (this is a segment of the full code) here is what i cant figure out after the following code is ran

cd /C "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa"
rename "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa" "SteamVR"
timeout 1 >nul
if exist "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa" (
echo Unknown Error
) else (
echo Steam Vr is Enabled, finished
)

if theres any errors not relating to this or ways the code can be better feel free to mention it as well im not very good with batch files

It comes up with the error "The filename, directory name, or volume label syntax is incorrect." But directly after that it then says "Steam Vr is Enabled, finished"

CodePudding user response:

cd /C "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa"

Is invalid and generating that message.

There is no /c option to cd.

The /d option would switch your current directory to "C:\Program Files (x86)\Steam\steamapps\common\SteamVRa"

If you change /c to /d you will get another error (The process cannot access the file because it is being used by another process.) The "other process is itself.

If you remove the cd altogether, the process works happily.

  • Related