Q: Switching the contents of one directory to another with Python I have 2 folders, let's call them dir1 and dir2. 
Is there a simple way to move all files from dir1 to dir2 and vice-versa?

A: I would use a third temporary folder:
from pathlib import Path
import shutil

def move_files(src_path, trg_path):
    for src_file in Path(src_path).glob('*.*'):
        shutil.copy(src_file, trg_path)

move_files('/path/to/dir1/', '/path/to/tmp/')
move_files('/path/to/dir2/', '/path/to/dir1/')
move_files('/path/to/tmp/', '/path/to/dir2/')

You need a temporary folder because there could be files that have the same name. The temporary folder must be empty.

A: The easiest approach would be just to rename, as @Lior Pollak notes.
from pathlib import Path
dir1 = Path("/path/to/dir1")
dir2 = Path("/path/to/dir2")

tmpname = dir2
i = 0
while tmpname.exists():
    tmpname = tmpname.with_suffix(f".tmp{i}")
    i += 1

left_path = dir1
dir1.rename(tmpname)
right_path = dir2
dir2.rename(left_path)
tmpname.rename(right_path)

Note that this code has a race condition if tnpname is created either as a non-empty dir or as a file by something else before the rename happens, or if dir1 is created (ditto) just after the rename.  This is likely not a problem in this application, but the alternative would be to wrap the renaming itself in a try/except loop:
tmpname = dir2.with_suffix(".tmp0")
left_path = dir1
i = 0
while True:
    try:
        dir1.rename(tmpname)
        break
    except OSError:
        i += 1
        tmpname = tmpname.with_suffix(f".tmp{i}")

This works by delegating the rename to the underlying os call, which is hopefully atomic (thus preventing the race condition).  The same thing can be done to handle the race condition with dir.  Whether this is actually worth doing depends on the environment you are running in, but it won't hurt.
