How can I convert a file path to an URI in the command-line?Example:/home/MHC/directory with spaces and mlutstofile:///home/MHC/directory%20with%20spaces%20and%20%C3%BCml%C3%A4uts
Convert file path to URI in bash
bash;filenames
One way to do this is using urlencode (install it on Ubuntu via sudo apt-get install gridsite-clients).urlencode -m $filepathwill convert the path to an URI. The file:// part of the URI will be left out, but you can easily add that via a bash one-liner:uri=$(urlencode -m $1); echo file://$urior directlyecho file://$(urlencode -m $1)orecho -n file://; urlencode -m $1Many thanks to Michael Kjrling for the references!