Pythontree
This project has been created to facilitate folder management
-
-
- pip
# pip3 install pythontree # pip3 install pythontree --upgrade
- git
$ git clone https://github.com/MattVoid/pythontree.git $ cd pythontree $ python3 setup.py install
- pip
-
- roots
it's a grapich function, print a tree of the chosen path>>> import pythontree >>> Roots = pythontree.Roots('*** you can choose the path to start ***') >>> Roots.roots()
- element
return an array with files or folders starting from your chosen path└─home └─Desktop ├─document │ └─setup.py ├─python │ └─try.py └─ruby └─try.rb
>>> import pythontree >>> Roots = pythontree.Roots('/home') # you can choose the path to start >>> print(Roots.element()['file']['path']) ['/home/Desktop/document/setup.py', '/home/Desktop/python/try.py', '/home/Desktop/ruby/try.rb'] >>> print(Roots.element()['file']['name']) ['setup.py', 'try.py', 'try.rb'] >>> print(Roots.element()['dir']['path']) ['/home/Desktop', '/home/Desktop/document', '/home/Desktop/python', '/home/Desktop/ruby'] >>> print(Roots.element()['dir']['name']) ['Desktop', 'document', 'python', 'ruby']
- type
return an array with files with an extension of your choice starting from your path>>> import pythontree >>> Roots = pythontree.Roots('/home') # you can choose the path to start >>> print(Roots.type('rb')['name']) # you can choose the extension to return ['try.rb'] >>> print(Roots.type('rb')['path']) ['/home/Desktop/ruby/try.rb']
- roots
-
- element
return an array with empty folders or equal files└─home └─Desktop ├─document │ └─setup.py ├─python │ ├─try.py │ ├─try(copy).py │ ├─try(copy 2).py │ └─pythontree.py ├─ruby │ └─try.rb └─project
>>> import pythontree >>> Clean = pythontree.Clean('/home') # you can choose the path to start >>> print(Clean.element()['empty']['path']) ['/home/Desktop/project'] >>> Clean.element()['empty']['name'] ['project'] >>> print(Clean.element()['duplicate']['path']) ['/home/Desktop/python/try(copy).py', '/home/Desktop/python/try(copy 2).py'] >>> print(Clean.element()['duplicate']['name']) ['try(copy).py','try(copy 2).py'] >>> print(Clean.element()['duplicate']['original']['path']) #original returns the reference file ['/home/Desktop/python/try.py','/home/Desktop/python/try.py'] >>> print(Clean.element()['duplicate']['original']['name']) ['try.py','try.py']
- delete
- files
delete equal files starting from your chosen path>>> import pythontree >>> Clean = pythontree.Clean('*** you can choose the path to start ***') >>> Clean.delete('files')
- dirs
delete empty folders starting from your chosen path>>> import pythontree >>> Clean = pythontree.Clean('*** you can choose the path to start ***') >>> Clean.delete('dirs')
- both
delete empty folders and equal files starting from your chosen path>>> import pythontree >>> Clean = pythontree.Clean('*** you can choose the path to start ***') >>> Clean.delete('both')
- files
- element