1

Short description of the problem:

I have some directories (dir_1,...dir_N) and want to merge them in a new directory (dir_X) but without copying all the files from those directories (would be a waste of memory). All directories are on the same pyhsical disk. Because files in dir_1,...,dir_N can have the same names I also need to give them new names in dir_X. If I walk through files in dir_X all those probably linked files shall be used/accessed like normal files.

I read a little bit about sym and hard links but don't know whats best to use. If I understand it write hardlinks are something like shared pointer to space on disk and sym links are something like normal pointer, spoken in C++ ;-) So I suppose hardlinks seems to meet best my requirements, right? How can create them with python for the required usage?

Thanks for help!

Feuerteufel
  • 571
  • 5
  • 16
  • 3
    Do you have some base code you started to give in an indication of where solutions could be provided? As it stands now, not too sure how much you already do or do not know. For now, what I suggest is looking at the `os` module for filesystem manipulation. Finally, look at `subprocess` for executing shell commands in Python. The shell command you are interested in is `ln` which creates a link. http://www.cyberciti.biz/faq/creating-hard-links-with-ln-command/ – idjaw Oct 30 '15 at 14:45
  • Thanks for the fast response, in the docu of python os module exists os.link for hardlinks and os.symlink for symbolic links. I should use os.link right? Then subprocess and ln is not necessary? – Feuerteufel Oct 30 '15 at 15:05
  • Good find! Give it a shot and see what happens. If it doesn't work, you can update your post to indicate the explicit problem you are having with it by indicating what you tried to do in your code, and why it is not behaving as expected. Good luck! – idjaw Oct 30 '15 at 15:08

0 Answers0