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\jasperser ver-ce-3.7 .0\scripts "
directory
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\jasperser
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"
How about just putting "CD\" to take yourself back to D:. then "CD TEST" to go into the test directory?
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:
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"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect thanks
d:\test OR d:\test\..\Java\jasperserv
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