def replace_root_with_path(run_command, path):
    """Replaces '"root/' with '"path_to_root/' and 'root/' with 
    '"path_to_root"/.
    """
    len_path = len(path)
    i = 0
    k = 0
    l = 0
    while k != -1:
        l += 1
        j = run_command[i:].find('"root/')
        k = run_command[i:].find('root/')
        if j < k and j != -1:
            run_command = run_command[:i + j] + '"' + path + '/' + run_command[
                i + j + 6:]
            i = i + j + len_path + 2
        elif k != -1:
            run_command = run_command[:i + k
                ] + '"' + path + '"/' + run_command[i + k + 5:]
            i = i + k + len_path + 3
    return run_command
