-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsymlink.py
More file actions
41 lines (34 loc) · 888 Bytes
/
symlink.py
File metadata and controls
41 lines (34 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
#This script only detects and removes softlinks. Other types of duplicate files wont be affected. Currently working on them too.
import os
from os import listdir
import os.path
links = ["" for x in range(1000)]
count=0
def scanvol():
global links
global count
for i in os.listdir(os.getcwd()):
if os.path.islink(i):
print i,' in directory: ',os.getcwd()
print ''
links[count] = os.getcwd()+"/"+i
count=count+1
if os.path.isdir(i):
os.chdir(i)
scanvol()
os.chdir('..')
def purge():
for x in range(count):
os.system('rm '+links[x])
vol_path = raw_input("Enter the path of the volume to be scanned: ")
os.chdir(vol_path)
print 'Following links are present in the current volume: '
scanvol()
while True:
choice = raw_input("Do you want to remove these links(Y/n): ")
if choice == "Y":
purge()
break
elif choice == "n":
break