Jul-30-2018, 11:27 PM
Ok so I been working with Linux for a few years now and I have finally decided to put file and folder linking into practice, considering I need files in multiple locations but i don't want to have dupes... So I'm writing a script to create links to files and folders as needed (where needed)
however I've run into a little discrepancy when running my completed script as opposed to manually creating symlinks
I have a folder 'sourcedir' located at the root of a drive and a folder "foo/bar/targetfolder" (relative to root of drive) which needs a link to the sourcedir folder inside it.
first i get the relative path
next i create the link
however if I create the link in a terminal with
I'd appreciate any help
however I've run into a little discrepancy when running my completed script as opposed to manually creating symlinks
I have a folder 'sourcedir' located at the root of a drive and a folder "foo/bar/targetfolder" (relative to root of drive) which needs a link to the sourcedir folder inside it.
first i get the relative path
relativepath = os.path.relpath('/sourcedir','/foo/bar/targetdir')which sets relatiivepath to '../../sourcedir'
next i create the link
os.symlink(relativepath,'/foo/bar/targetdir/targetlink)')if I go to my filemanager and delete the created 'targetlink' it starts deleting all the files in the linked folder
however if I create the link in a terminal with
Quote:ln -s relativepath /foo/bar/targetdir/targetlink'the profuced symlink shows in my filemanager with a shortcut arrow on it and deleting it simply deletes the link and nothing else. This is the behaviour I'm aiming for and I can't figure out how to get python to do that for me.
I'd appreciate any help