SWAPNAMES — Exchange two files.

Syntax:
SWAPNAMES /D /Q /X file1 file2

/Dfile1 and file2 are directories, not files
/Qquietly
/Xcheck that file1 and file2 have the same file type
file1, file2required; wildcards not allowed

This command does a double rename. It renames file1 as file2, and vice versa. It only renames one pair of files; wildcards are not supported.

/X gets both files’ extensions, and reads their default handlers from the registry. It allows the rename only if both extensions are the same, or if both have the same handler. For example, you can swap a .txt file with a .log file only if they have the same handler. /X is ignored with /D.

swapnames myfile.cpp myfile.bak