https://github.com/d-krupke/folder_anchor
A tool for automatically creating symbolic links.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.9%) to scientific vocabulary
Repository
A tool for automatically creating symbolic links.
Basic Info
- Host: GitHub
- Owner: d-krupke
- Language: Python
- Default Branch: master
- Size: 20.5 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
folder_anchor
A tool for automatically creating symbolic links.
I found myself in the situation that my working folders and files where distributed around multiple repositories, cloud folders, etc. which makes it hard to find the files you are looking for. For some time, I ordered everything by subject and sometimes used symbolic links. However, due to the vast amount of projects and tasks, a continuous reordering is necessary (which makes links bad). Further, projects and tasks are often not strictly separated which makes the subject based approach hard. Symbolic links are great to have a folder/file at multiple places but they are hard to maintain in a continuously evolving folder hierarchy. Thus, I started to develop folder_anchor which uses json files to describe the relationship between folders. More specifically to create named 'anchors' a folder can automatically be linked to. For example a Powerpoint folder on OneDrive for Project1 can automatically be linked to /Subjects/Area1/Project1/Powerpoint just by saying, that this should be a Powerpoint-folder in the Project1 folder. The tool will automatically scan through the directories and add or update the symbolic links to match the description.
Anchors and link requests are defined in json files with the name '.folderanchor.json' in the corresponding directory. Such a link can look as follows: ```json {"anchor": [{"name": "myanchor"}, {"name": "alternativename"}], "makepartof": [{"anchor": "someotheranchor", "subdir": "createasubdirwiththisname"}, {"anchor": "yetanotheranchor", "name": "namethislinkdifferently", "file": "dontlinktothefolderbuttothisfile"}], "name": "defaultnameoflink"} ```
Usage
``` usage: folder_anchor.py [-h] [-a,--anchor ANCHOR_NAME] [-t,--makepartof ANCHORNAME] [--subdir ./PATH] [--name NAME] [--file ./FILE] [--scan PATH] [-l,--listanchors PATH]
folderanchor is a tool for automaticallycreating symbolic links based on localjson configuration files. See https://github.com/d-krupke/folderanchor for more.
optional arguments: -h, --help show this help message and exit -a,--anchor ANCHORNAME Create anchor -t,--makepartof ANCHORNAME Link to anchor --subdir ./PATH Creates a subdir at the corresponding anchor --name NAME Name of the link (if different from folder name) --file ./FILE Don't like to the folder but this file. --scan PATH Scans the directory and adds missing symbolic links. -l,--list_anchors PATH Lists all anchors
```
Creating an anchor
An anchor is a folder that one can push symbolic links to. For example it makes sense to create an anchor for a project folder. Now you can have a repository in your repository folder and can tell it to create a link to it in the anchor's, i.e. project's, folder. Or you could create a 'latex' anchor that automatically gets a latex template folder linked to.
folder_anchor.py -a my_project
creates an anchor named "myproject" for the current folder.
This means it creates the file `.folderanchor.jsonwith the content
json
{"anchor": [{"name": "my_project"}]}
We can have multiple anchors on the same folder.
Calling
folderanchor.py -a latexproject
would modify the file to
json
{"anchor": [{"name": "my_project"}, {"name": "latex_project"}]}
`
Linking to an anchor
Assume you have a folder with latex templates and you want to create a
link named 'latextemplates' in every folder that has the anchor 'latexproject'.
For this you execute in your template folder
folder_anchor.py --make_part_of latex_project --name latex_templates
This creates the file
json
{"make_part_of": [{"anchor": "latex_project", "name": "latex_templates"}]}
Note that --name is optional (default is the original folder name).
If you want to put all templates in a subdirectory 'templates' you can add the
parameter --subdir templates.
Same as for anchors, you can add multiple such auto-links.
If you want to link a specific file in this directory, you can use the parameter --file.
Creating the links
If you call python3 folder_anchor.py -s ., it scans all the folders in the current directory
and creates the symbolic links specified in the .folder_anchor.json files.
This can take a few seconds if you have a lot of folders.
Design Decisions
Why not allow regular expressions?
It is useful to link some folder (for example templates) to all projects of a specific kind. However, since it is possible for a project folder to have multiple anchor names, there is no need for this. Just add a corresponding additional anchor to all the corresponding projects. There is also no harm in overlapping definitions if they have the same result (the tool will automatically detect this).
Does the tool overwrite any files with a wrong configuration?
No, the tool never deletes any files or folders. This also means you
have to take care of removing broken links. This is possible with
find -L $MY_DIRECTORY -type l -exec rm -- {} +.
When creating new symbolic links, only broken links are allowed to be overwritten.
Otherwise, a warning is printed.
Is there a dry run option?
Yes, simply add the parameter --dry to get the changes printed without actually performing them.
Owner
- Name: Dominik Krupke
- Login: d-krupke
- Kind: user
- Location: Germany
- Company: TU Braunschweig
- Website: https://krupke.cc
- Repositories: 8
- Profile: https://github.com/d-krupke
Postdoc at TU Braunschweig, IBR, Algorithms Group.
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0