Categories instead of directories. Tool for easy file storage

Inspired by the article


"Categories instead of directories, or the Semantic file system for Linux Vitis",

I decided to make my own analogue of the vitis utility for PowerShell Core.


Why did I start to do this?


First, vitis for Linux only.
Secondly, I want to use pipes in PowerShell.


Since I wanted to make a cross-platform utility, I chose .Net Core.


Background


At first there was chaos. Then folders appeared on the disk.
But chaos still reigned. And tags appeared, as well as subtags and synonyms for tags. But chaos captured them too. And categories were invented.


Concept


Files are not stored in a folder hierarchy, but in a heap, with certain categories. A single file can belong to several categories.


If you need to find a file, it is more convenient to enter the categories to which it belongs. It is much easier to remember than in what folders it is stored.


But such a file system is by no means suitable for storing code, source codes, etc.
It is designed to store, for example, family photos, music, documents.


Using


Well, let's start the demonstration.


Install Graphile:


 # install.ps1       PS D:\Source\repos\Graphile> .\install.ps1 

First, initialize Graphile in the folder:


 #    PS C:\Users\Dell\GraphileTest> Import-Module GraphilePowerShell #  Graphile   PS C:\Users\Dell\GraphileTest> Init-Graphile C:\Users\Dell\GraphileTest\graphile.db 

So, we are all set up. Now you can create a new category:


 PS C:\Users\Dell\GraphileTest> New-Category -Name "music" music 

Add the files:


 PS C:\Users\Dell\GraphileTest> Get-ChildItem "D:\Music\Pink Floyd - The Wall" -Recurse -Filter "*.mp3" | foreach { $_.FullName } | foreach { >> Add-FileToCategory -File $_ -Categories "music" >> } 

To those who did not understand what I did:


  1. Got a list of files in the Pink Floyd - The Wall folder Pink Floyd - The Wall
  2. Each file converted to a full path to them
  3. Added each file to the music category

Now check if we really added the files to the category:


 PS C:\Users\Dell\GraphileTest> List-Graphiles | Format-Table 

A list will be displayed in the format:


 CategoriesNames Id Categories Name Extension 

Add more categories and files:


 New-Category -Name "the-wall" New-Category -Name "alan-parsons" List-Graphiles -Categories "music" | foreach { Add-GraphileToCategory -Categories "the-wall" -Files $_.Name } Get-ChildItem "D:\Music\The Alan Parsons Project - Turn of a Friendly Card" -File -Recurse | foreach { $_.FullName } | foreach { Add-FileToCategory -File $_ -Categories "music", "alan-parsons" } 

Check the files:


 List-Graphiles -Categories "alan-parsons" | Format-Table 

The command will list all files that belong to the alan-parsons .


More files to the god of file systems!


 New-Category -Name "images" Get-ChildItem "D:\" -File -Recurse | foreach { $.FullName } | foreach { Add-FileToCategory -File $_ -Categories "images" } 

We check:


 List-Graphiles -Categories "images" | Format-Table 

Everything is working!


But this is only the beginning. Export your regular file system to Graphile and get great file organization.


Where to download Graphile


Here is a link to the GitLab Graphile.


MIT , so you can use it even for commercial purposes.


Future project


Since this is PowerShell, not khukh-mukhra, you can make a graphical shell under .NET Core.


How to do it:


  1. Install Microsoft.PowerShell.SDK
  2. Use the PowerShell class and call Graphile.

If you liked the project, make commits, merge request 's and create discussions.


Thanks for reading! Use and enjoy!



Source: https://habr.com/ru/post/467701/


All Articles