Link to home
Start Free TrialLog in
Avatar of Tagom
Tagom

asked on

changing directory in bat file

I am working on creating a bat file/script
what i need to do at the end of the file is change to another directory.
Current code:

suggestions on how I can get this to work....currently the result is to stay in the
cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
directory
@echo off
@echo off
cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "jsUnzip.bat [Start]"

if exist "\java\jasperreports-server-cp-4.0.0" exit

cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "jsExport.bat [Start]"

echo Exporting Repository to D:\test\JasperServer\Repository_updated (users, connections, a test report, etc.)  Please wait...

cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "exporting Jasper Repository"

cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1

CHDIR "d:\test"

Open in new window

Avatar of OrenRozen
OrenRozen
Flag of Israel image

I do not completely understand at what folder you'd like to end with.
d:\test OR d:\test\..\Java\jasperserver-ce-3.7.0\scripts

another thing, in your command you use .. in the path. that means go 1 folder down.
so basically if I'm in the folder (for example) d:\test and I type cd d:\..\test, I'll stay in the same folder.

Thanks
How about just putting "CD\" to take yourself back to D:. then "CD TEST" to go into the test directory?
Avatar of oBdA
oBdA

If your script is started from any drive other than D:, any "cd D:\..." will not work as you expect it to; I suspect that the "cd" in line 13 isn't working, either.
You can either use complete paths (recommended), or always use "cd /d" which will change the directory as well as the drive:
cd /d "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1
CHDIR /d "d:\test"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tagom

ASKER

perfect thanks