user7610849
user7610849

Reputation:

Changing current working folder for a batch file

I have a problem with a batch file

This is the batch file:

del mod.ff

xcopy ui_mp ..\..\raw\ui_mp /SY
xcopy english ..\..\raw\english /SY
xcopy ui ..\..\raw\ui /SY
xcopy sound ..\..\raw\sound /SY
xcopy soundaliases ..\..\raw\soundaliases /SY
xcopy promod ..\..\raw\promod /SY
xcopy maps ..\..\raw\maps /SY
xcopy mp ..\..\raw\mp /SY
xcopy shock ..\..\raw\shock /SY
xcopy xmodel ..\..\raw\xmodel /SY
xcopy shock ..\..\raw\shock /SY
xcopy readme.txt ..\..\raw /SY
copy /Y mod.csv ..\..\zone_source
cd ..\..\bin
linker_pc.exe -language english -compress -cleanup mod
cd ..\Mods\PromodLive218
copy ..\..\zone\english\mod.ff

pause

When I run it it starts doing all the commands, (starts searching) in C:\WINDOWS\System32 rather than the folder in Program Files the batch file is in....

How do I change that? How do I set the current working folder to the directory the batch file is in rather than the WINDOWS system32 directory?

When I run it I get this:

C:\WINDOWS\system32>del mod.ff

Could Not Find C:\WINDOWS\system32\mod.ff

It should search in C:\Program Files (x86)\ itd itd itd, how do I make it search in Program Files rather than System32?

Upvotes: 0

Views: 5131

Answers (1)

Stephan
Stephan

Reputation: 56155

To change the working folder, use the cd command.
Within a batchfile, you have way to get the folder where the batchfile resides:

cd /d "%~dp0"

Simply put that command at the start of your script.

Upvotes: 5

Related Questions