Skip to main content
explain that you need to run this code...
Source Link
gogoud
  • 1.4k
  • 1
  • 9
  • 12

See below, you need to change the 4 variables to match your needs. Save this code, suitably modified, as a batch file (.bat extension), and then run it from the command line (or from Run/Start).

@ECHO OFF
SETLOCAL
REM location is the directory below the one you want to rename
SET location=%USERPROFILE%\Documents
SET mydir_pre=testdir1
SET mydir_post=testdir2
SET myprogram=C:\windows\system32\notepad.exe

RENAME "%location%\%mydir_pre%" "%mydir_post%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_pre%"&&GOTO :eof
REM start the program, while you are using this instance you will see testdir2
START "My Program" /WAIT "%myprogram%"||ECHO Unable to start %myprogram%&&GOTO :eof
RENAME "%location%\%mydir_post%" "%mydir_pre%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_post%"&&GOTO :eof
ECHO Successful completion
ENDLOCAL

See below, you need to change the 4 variables to match your needs.

@ECHO OFF
SETLOCAL
REM location is the directory below the one you want to rename
SET location=%USERPROFILE%\Documents
SET mydir_pre=testdir1
SET mydir_post=testdir2
SET myprogram=C:\windows\system32\notepad.exe

RENAME "%location%\%mydir_pre%" "%mydir_post%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_pre%"&&GOTO :eof
REM start the program, while you are using this instance you will see testdir2
START "My Program" /WAIT "%myprogram%"||ECHO Unable to start %myprogram%&&GOTO :eof
RENAME "%location%\%mydir_post%" "%mydir_pre%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_post%"&&GOTO :eof
ECHO Successful completion
ENDLOCAL

See below, you need to change the 4 variables to match your needs. Save this code, suitably modified, as a batch file (.bat extension), and then run it from the command line (or from Run/Start).

@ECHO OFF
SETLOCAL
REM location is the directory below the one you want to rename
SET location=%USERPROFILE%\Documents
SET mydir_pre=testdir1
SET mydir_post=testdir2
SET myprogram=C:\windows\system32\notepad.exe

RENAME "%location%\%mydir_pre%" "%mydir_post%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_pre%"&&GOTO :eof
REM start the program, while you are using this instance you will see testdir2
START "My Program" /WAIT "%myprogram%"||ECHO Unable to start %myprogram%&&GOTO :eof
RENAME "%location%\%mydir_post%" "%mydir_pre%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_post%"&&GOTO :eof
ECHO Successful completion
ENDLOCAL
Source Link
gogoud
  • 1.4k
  • 1
  • 9
  • 12

See below, you need to change the 4 variables to match your needs.

@ECHO OFF
SETLOCAL
REM location is the directory below the one you want to rename
SET location=%USERPROFILE%\Documents
SET mydir_pre=testdir1
SET mydir_post=testdir2
SET myprogram=C:\windows\system32\notepad.exe

RENAME "%location%\%mydir_pre%" "%mydir_post%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_pre%"&&GOTO :eof
REM start the program, while you are using this instance you will see testdir2
START "My Program" /WAIT "%myprogram%"||ECHO Unable to start %myprogram%&&GOTO :eof
RENAME "%location%\%mydir_post%" "%mydir_pre%" 2>NUL||ECHO Oops - failed to rename "%location%\%mydir_post%"&&GOTO :eof
ECHO Successful completion
ENDLOCAL