(1) you have a lot of duplication in both examples, and duplication is the enemy of maintainable code. The first consideration must be removing it.
(2) a lot of people have an aversion to the use of the alternation operator (
?:), but frankly in situations like this, it's use can make code a lot clearer. Therefore, as long as
condition is something relatively simple, of suggest this as an alternative:
cd ("/path/to" + (condition ? "file1" : "file2"))
For a task like this, i think brevity is highly beneficial.
Now, of the logic is any more complex than this, I'd suggest factoring out choice of the file path to a separate function, but at this level of complexity (and as long as it only occurs in one place) I think doing it online like this is fine.