The following example shows how you can use the
pushd
command and thepopd
command in a batch program to change the current directory from the one in which the batch program was run and then change it back:@echo off rem This batch file deletes all .txt files in a specified directory pushd %1 del *.txt popd cls echo All text files deleted in the %1 directory
Sourced from https://technet.microsoft.com/en-us/library/cc771180%28v=ws.11%29.aspx