Reputation: 1
I am working on organizing a folder on my Windows computer. I want to write some Python code to create links inside a new folder which will allow the user to click the created links and it will take the user to the original folder.
So, for example, say this is Folder 1: asparagus bananas carrots oranges pineapples
and this is the new folder which I want to create links to Folder 1: fruits vegetables
Is this doable in Python?
I have been looking into detail about using the recursion function in Python.
Also, the folders I displayed above are extremely simple. My actual folders are full of files and additional files so keep that in mind. This is why I think recursion might be the way to go.
Upvotes: 0
Views: 614
Reputation: 3545
you can use symlink:
os.symlink(src, dst)
Here is an example from this link:
import os
src = '/usr/bin/python'
dst = '/tmp/python'
# This creates a symbolic link on python in tmp directory
os.symlink(src, dst)
print "symlink created"
Example:
Assume you have folder D:/Folder1
where is folder D:/Folder1/oranges
and if you want to create symlink of this folder in D:/Fruits
you should do that:
import os
os.symlink('D:/Folder1/oranges', 'D:/Fruits/oranges')
Upvotes: 1