Question

I'm working with some Python scripts that operate on files (compress them, calculate sizes, etc.) and create some other files (distance matrix, file sizes list, etc.). I have different groups of files that I need to keep separate (in one folder I have txt files, in another I have some midis...). Now I have a copy of the scripts in every folder (the txt folder, the midis folder...) but it's a mess, because I forget which one is the most recent.

My question is: is there a way to keep the scripts in just one folder (for example ./stuff/scripts) so that I can run them from the different filetype folders (./stuff/midi, ./stuff/txt) without having copies in each directory?

I'm new to Python and a newbie programmer, is this just a wrong approach?

Thanks!

Was it helpful?

Solution

there are many ways to do this properly, but the easiest way for a beginner is to put them all in one folder, e.g. src and put that next to the midi and txt folder. that way you can run them using relative paths like this:

python ../src/script1.py

the .. moves you up (from e.g. midi to stuff) and from there you navigate to the proper path.

later you can learn about setting your $PATH, modules and much more...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top