Extract and changedir generically.