Inspired
«Категории вместо директорий, или Семантическая файловая система для Linux Vitis»,
I decided to make my own analogue of the utility vitis for PowerShell Core.
Why did I start doing this
First of all, vitis only for Linux.
Secondly, I want to use "pipes" in PowerShell.
Since I wanted to make a cross-platform utility, I chose .Net Core.
prehistory
First there was chaos. Then folders appeared on the disk.
But chaos still reigned. And tags appeared, as well as subtags and tag synonyms. But chaos captured them too. And the categories were invented.
Concept
Files are not stored in a folder hierarchy, but in a "heap", with certain categories. One 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. This is much easier to remember than what folders it is stored in.
But such a file system is by no means suitable for storing code, sources, 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:SourcereposGraphile> .install.ps1First we initialize Graphile in the folder:
# Импортируем установленный модуль
PS C:UsersDellGraphileTest> Import-Module GraphilePowerShell
# Инициализируем Graphile в папке
PS C:UsersDellGraphileTest> Init-Graphile
C:UsersDellGraphileTestgraphile.dbSo we've got everything set up. Now you can create a new category:
PS C:UsersDellGraphileTest> New-Category -Name "music"
musicLet's add files:
PS C:UsersDellGraphileTest> Get-ChildItem "D:MusicPink Floyd - The Wall" -Recurse -Filter "*.mp3" | foreach { $_.FullName } | foreach {
>> Add-FileToCategory -File $_ -Categories "music"
>> }For those who don't understand what I did:
- Got a list of files in a folder
Pink Floyd - The Wall - Each file is converted to the full path to them
- Added each file to a category
music
Now let's check if we really added files to the category:
PS C:UsersDellGraphileTest> List-Graphiles | Format-TableThe list will be displayed in the format:
CategoriesNames Id Categories Name ExtensionLet's 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:MusicThe Alan Parsons Project - Turn of a Friendly Card" -File -Recurse | foreach { $_.FullName } | foreach { Add-FileToCategory -File $_ -Categories "music", "alan-parsons" }Let's check the files:
List-Graphiles -Categories "alan-parsons" | Format-TableThe command will display all files that belong to the category alan-parsons.
More files for the filesystem god!
New-Category -Name "images"
Get-ChildItem "D:Изображения" -File -Recurse | foreach { $.FullName } | foreach {
Add-FileToCategory -File $_ -Categories "images"
}We check:
List-Graphiles -Categories "images" | Format-TableEverything 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 on GitLab Graphile.
License MITso you can even use it for commercial purposes.
Future project
Since this is PowerShell, and not huh-muhry, you can make a graphical shell for .NET Core.
How to do it:
- Install Microsoft.PowerShell.SDK
- Use the PowerShell class and call Graphile.
If you like the project, make commits, merge request's and create discussions.
Thanks for reading! Use and enjoy!
Source: habr.com
