Urial (URI Addition tooL) intelligently updates URIs stored in Finder comments of macOS files

Overview

Urial

Urial (URI addition tool) is a simple but intelligent command-line tool to add or replace URIs found inside macOS Finder comments.

License Python DOI Latest release PyPI

Table of contents

Introduction

Urial is a command-line program written in Python 3 that allows you to write and update URIs in the Finder comments of a file. Urial makes it easier to write scripts (e.g., in Bash/Bourne shell syntax, or AppleScripts) that keep those URIs updated.

Incidentally, urial (properly known as Ovis vignei) are a kind of wild sheep native to Central and South Asia. They are listed as a vulnerable species and their population continues to twindle due to human activity, hunting, and climate change.

Installation

There are multiple ways of installing Urial, ranging from downloading a self-contained, single-file, ready-to-run program, to installing it as a typical Python program using pip. Please choose the alternative that suits you.

Alternative 1: installing Urial using pipx

You can use pipx to install Urial. Pipx will install it into a separate Python environment that isolates the dependencies needed by Urial from other Python programs on your system, and yet the resulting urial command wil be executable from any shell – like any normal program on your computer. If you do not already have pipx on your system, it can be installed in a variety of easy ways and it is best to consult Pipx's installation guide for instructions. Once you have pipx on your system, you can install Urial with the following command:

pipx install urial

Pipx can also let you run Urial directly using pipx run urial, although in that case, you must always prefix every Urial command with pipx run. Consult the documentation for pipx run for more information.

Alternative 2: installing Urial using pip

The instructions below assume you have a Python 3 interpreter installed on your computer. Note that the default on macOS at least through 10.14 (Mojave) is Python 2 – please first install Python version 3 and familiarize yourself with running Python programs on your system before proceeding further.

You should be able to install urial with pip for Python 3. To install urial from the Python package repository (PyPI), run the following command:

python3 -m pip install urial

As an alternative to getting it from PyPI, you can use pip to install urial directly from GitHub:

python3 -m pip install git+https://github.com/mhucka/urial.git

If you already installed Urial once before, and want to update to the latest version, add --upgrade to the end of either command line above.

Alternative 3: installing Urial from sources

If you prefer to install Urial directly from the source code, you can do that too. To get a copy of the files, you can clone the GitHub repository:

git clone https://github.com/mhucka/urial

Alternatively, you can download the files as a ZIP archive using this link directly from your browser using this link: https://github.com/mhucka/urial/archive/refs/heads/main.zip

Next, after getting a copy of the files, run setup.py inside the code directory:

cd urial
python3 setup.py install

Usage

This program expects to be given at least two argument values. The first value is taken to be a string containing a URI, and the second value is the path of a file whose Finder comment should be updated with the given string. Optional arguments begin with dashes and modify the program's behavior.

By default, if file already has any Finder comment, it is only modified to update the substring that has the same type of URI, and then only if the Finder comment contains such a substring. For example, if the file "somefile.md" contains a Finder comment with an existing x-devonthink-item URI inside of it, then the following command,

urial "x-devonthink-item://8A1A0F18-068680226F3" somefile.md

will rewrite the URI part of the comment to have the new URI given on the command line. If the Finder comment is not empty but does not contain a URI of the same kind as the one given on the command line, then the Finder comment is not changed unless a suitable value for the option --mode is given (see below).

Urial users regular expression pattern matching to find the same kind of URI as the value you provide on the command line, to make it more robust against accidentally matching other URIs that may exist in a Finder comment. So, for example, If you supply a URI that has a x-devonthink-item scheme type, it will look only for x-devonthink-item URIs and will not match other URIs; if you supply a URI that has a zotero scheme type, it will look only for those URIs; and so on.

Handling existing Finder comments

If the file already has a Finder comment, the default behavior of urial is to first check if the comment contains a URI of the same scheme as the given URI; if it does, urial replaces the URI (and just the URI) substring in the Finder comment, and if it does not, urial instead appends the URL to the comment. The --mode option can be used to change this behavior, as follows:

  • append: if the URI is NOT found in the Finder comment string, append the given URI to the end of the comment; otherwise (if the comment string already contains the URI) do nothing
  • overwrite: overwrite the Finder comment completely with the given URI string, no matter what the Finder comment string contains (even if it already contains the given URI)
  • update: (default) if a URI of the same kind exists in the comment, replace only the URI portion of the comment string (preserving the rest of the comment string), else (if a URI is NOT found in the comment string) do nothing

Note that the behavior of --mode overwrite is to replace unconditionally the entire Finder comment. In other words, -- mode overwrite will change a Finder comment such as

Blah blah blah. URI. More blah blah blah.

to just

URI

assuming that URI is the URI given to urial on the command line. If you want to update the URI to a new value and leave the other comment text in place, use --mode update or simply don't provide a value for --mode (because update is the default action).

Additional command-line arguments

If given the --version option, this program will print the version and other information, and exit without doing anything else.

By default, this program will use macOS dialogs to report errors or other issues. The option --no-gui will make it print messages only on the command line, without using GUI dialogs.

If given the --debug argument, this program will output a detailed trace of what it is doing. The trace will be sent to the given destination, which can be - to indicate console output, or a file path to send the output to a file.

Getting help

If you find an issue, please submit it in the GitHub issue tracker for this repository.

Contributing

I would be happy to receive your help and participation if you are interested. Everyone is asked to read and respect the code of conduct when participating in this project. Development generally takes place on the development branch.

License

This software is Copyright (C) 2021, by Michael Hucka and the California Institute of Technology (Pasadena, California, USA). This software is freely distributed under a 3-clause BSD type license. Please see the LICENSE file for more information.

Acknowledgments

This work is a personal project developed by the author, using computing facilities and other resources of the California Institute of Technology Library.

The vector artwork of a sheep with horns, used as the icon for Urial, was created by Vectors Point from the Noun Project. It is licensed under the Creative Commons CC-BY 3.0 license.

Urial makes use of numerous open-source packages, without which Urial could not have been developed. I want to acknowledge this debt. In alphabetical order, the packages are:

  • appscript – high-level Apple event bridge that allows you to control scriptable Mac OS X applications
  • plac – a command line argument parser
  • setuptools – library for setup.py
  • Sidetrack – simple debug logging/tracing package
  • wheel – setuptools extension for building wheels
You might also like...
Tidier - a simple command line tool that helps you make your files tidy up

Tidier - a simple command line tool that helps you make your files tidy up

Shortcut-Maker - It is a tool that can be set to run any tool with a single command
Shortcut-Maker - It is a tool that can be set to run any tool with a single command

Shortcut-Maker It is a tool that can be set to run any tool with a single command Coded by Dave Smith(Owner of Sl Cyber Warriors) Command list 👇 pkg

PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything.After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands.
QueraToCSV is a simple python CLI project to convert the Quera results file into CSV files.

Quera is an Iranian Learning management system (LMS) that has an online judge for programming languages. Some Iranian universities use it to automate the evaluation of programming assignments.

Management commands to help backup and restore your project database and media files

Django Database Backup This Django application provides management commands to help backup and restore your project database and media files with vari

uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal.

uploadgram uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal. Heavily inspired by the telegram-upload Installing: pi

💥 Share files easily over your local network from the terminal!
💥 Share files easily over your local network from the terminal!

Fileshare 📨 Share files easily over your local network from the terminal! 📨 Installation # clone the repo $ git clone https://github.com/dopevog/fil

Doing set operations on files considered as sets of lines

CLI tool that can be used to do set operations like union on files considering them as a set of lines. Notes It ignores all empty lines with whitespac

commandpack - A package of modules for working with commands, command packages, files with command packages.
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

Releases(v1.0.0)
  • v1.0.0(Dec 27, 2021)

    This is the first public release of Urial. This version improves parsing of URIs in Finder comments, and the release now includes ready-to-run binary executables for macOS.

    Self-contained runnable copies of Urial

    Copies of ready-to-run executable versions of Urial are included with this release. They need a Python interpreter version 3.8 or higher installed on your computer. Happily, that's the case for macOS 10.15 and later. To be sure, first check the version of the program python3 that you get by running the following command in a terminal and inspecting the results:

    python3 --version
    

    (Note: if this is the first time you've run python3 on your system, macOS will ask if you want to install certain additional software components. Let it do so.) Make sure the version is at least 3.8. Note that if you are running a macOS version before 10.15, you will need to manually install Python 3.8 or later.

    Next,

    1. In the files attached to this release, look for a ZIP file with a name that contains your version of Python
    2. Click on that ZIP file to download it
    3. Unzip the file (if your browser did not automatically unzip it for you)
    4. Open the folder thus created (it will have a name like urial-1.0.0-macos-python3.8)
    5. Look inside for urial and move it to a location where you put other command-line programs (such as /usr/local/bin).

    If you want to put it in /usr/local/bin but that folder does not exist on your computer yet, you can create it by opening a terminal window and running the following command (prior to moving urial into /usr/local/bin):

    sudo mkdir /usr/local/bin
    

    The following is an example command that you can type in a terminal to move Urial there:

    sudo mv urial /usr/local/bin
    
    Source code(tar.gz)
    Source code(zip)
    urial-1.0.0-macos-python3.10.zip(1.05 MB)
    urial-1.0.0-macos-python3.8.zip(1.06 MB)
    urial-1.0.0-macos-python3.9.zip(1.06 MB)
  • v0.0.4(Dec 26, 2021)

  • v0.0.3(Dec 26, 2021)

  • v0.0.2(Dec 7, 2021)

  • v0.0.1(Dec 7, 2021)

Owner
Mike Hucka
Software & standards for scientific applications, data exchange, knowledge preservation. Background: comp. sci. & cognitive science. ORCID: 0000-0001-9105-596
Mike Hucka
Simple Python Library to display text with color in Python Terminal

pyTextColor v1.0 Introduction pyTextColor is a simple Python Library to display colorful outputs in Terminal, etc. Note: Your Terminal or any software

Siddhesh Chavan 1 Jan 23, 2022
pls is a better ls for developers, pronounced /pliːz/ as in 'please'

pls is a better ls for developers. The "p" stands for ("pro" as in "professional"/"programmer") or "prettier". It works in a manner similar to ls, in

Dhruv Bhanushali 572 Dec 28, 2022
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
Magma is a NeoVim plugin for running code interactively with Jupyter.

Magma Magma is a NeoVim plugin for running code interactively with Jupyter. Requirements NeoVim 0.5+ Python 3.8+ Required Python packages: pynvim (for

Daniel Csillag 372 Dec 26, 2022
dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project

dbt-subdocs dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project 🤔 Description This project is useful if

Jambe 6 Jan 03, 2023
The most comprehensive, exhaustive, parameterized command-line wordle solver.

Wordle Solver The most comprehensive, exhaustive, parameterized command-line wordle solver. Wordle is a real

Debarghya Das 27 Nov 21, 2022
TermPair lets developers securely share and control terminals in real time🔒

View and control terminals from your browser with end-to-end encryption 🔒

Chad Smith 1.5k Jan 05, 2023
PipeCat - A command line Youtube music player written in python.

A command line Youtube music player written in python. It's an app written for Linux. It also supports offline playlists that are stored in a

34 Nov 27, 2022
Apple Silicon 'top' CLI

asitop pip install asitop What A nvtop/htop style/inspired command line tool for Apple Silicon (aka M1) Macs. Note that it requires sudo to run due to

Timothy Liu 1.2k Dec 31, 2022
A CLI tool that scans through a directory and organizes all loose files into folders by file type.

Organizer CLI Organizer CLI is a python command line tool that goes through a given directory and organizes all un-folder bound files into folders by

Mulaza Jacinto 6 Dec 14, 2022
🌈 Beautify your command line interfaces.

Basics Install: pip install iridi Usage: import iridi # Create gradient text # iridi.print(message, colors, options) # Ask for input with gradient

Conrad Crawford 39 Oct 20, 2022
A small system that allow you to manage hosts stored in your .ssh/config file

A small system that allow you to manage hosts stored in your .ssh/config using simple commands.

Simone Ostini 1 Jan 24, 2022
dotfilery, configuration, environment settings, automation, etc.

┌┬┐┌─┐┌─┐┌─┐┬ ┬┌┬┐┬ ┬┬┌─┐ │││├┤ │ ┬├─┤│ │ │ ├─┤││ :: bits & bobs, dots & things. ┴ ┴└─┘└─┘┴ ┴┴─┘┴ ┴ ┴ ┴┴└─┘ @megalithic 🚀 Instal

Seth Messer 89 Dec 25, 2022
This is a command line program to play cricket made using Python.

SimpleCricketPython This is a command line program to play cricket made using Python How it works First you have the option of selecting whether you

Imira Randeniya 1 Sep 11, 2022
texel - Command line interface for reading spreadsheets inside terminal

texel - Command line interface for reading spreadsheets inside terminal. Sometimes, you have to deal with spreadsheets. Those are sad times. Fortunate

128 Dec 19, 2022
Tstock - Check stocks from the terminal

tstock - Check stocks from the terminal! 📈 tstock is a tool to easily generate stock charts from the command line. Just type tstock aapl to get a 3 m

Gabe Banks 502 Dec 30, 2022
Fun project to generate The Matrix Code effect on you terminal.

Fun project to generate The Matrix Code effect on you terminal.

Henrique Bastos 11 Jul 13, 2022
[WIP]An ani-cli like cli tool for movies and webseries

mov-cli A cli to browse and watch movies. Installation This project is a work in progress. However, you can try it out python git clone https://github

166 Dec 30, 2022
Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016"

deconvnet_analysis Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016" Parts of this code Generate figures in t

Aravindh Mahendran 12 Jan 25, 2021
A Tempmail Tool for Terminal and Termux.

A Tempmail Tool for Terminal and Termux.

MAO-COMMUNITY 8 Oct 19, 2022