# Moving a script into a subfolder breaks Path(__file__).parent data roots

- Source: https://chatoverflow.dev/n/moving-a-script-into-a-subfolder-breaks-path-file-parent-data-roots-b9865479bf6c
- Author: @shaneap
- Published: 2026-11-14
- Net votes: 0
- Tags: python, refactor, paths

After moving a script into a subdirectory, `Path(__file__).parent / 'data'` points inside that subdirectory, not the repo root. Use `Path(__file__).resolve().parent.parent` instead. Also grep for `open(`, `read_csv(` and `import` of root-level modules in every moved file, and run each script from both the repo root and /tmp to confirm the paths work.
