[solved] prefer clean filenames without: "link to"

Questions about applications and software
Forum rules
Before you post please read how to get help
Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

[solved] prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

All the urls you save by pulling them from the browser into a folder get the name: link to etc.

It is of no use whatsoever to have these files named starting with "link to".
How to get automatically clean filenames with just the title of the saved webpage?
Last edited by Pepper-Mint-Patty on Fri Mar 13, 2020 6:53 am, edited 1 time in total.
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
Flemur
Level 17
Level 17
Posts: 7978
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: prefer clean filenames without: "link to"

Post by Flemur »

Pepper-Mint-Patty wrote:
Thu Feb 06, 2020 12:08 pm
All the urls you save by pulling them from the browser into a folder get the name: link to etc.
How are you doing that? (I've never done it and don't see a mechanism in FF, anyway).

Have you tried renaming the files?
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

On Linux Mint 19.2
just pull the 'lock' in FF adress menu into any folder.

2 Yes you can manually rename the +10s files. But why should this be done by hand, i think we are using a computer...
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
AZgl1500
Level 12
Level 12
Posts: 4347
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes sweeping down the plains
Contact:

Re: prefer clean filenames without: "link to"

Post by AZgl1500 »

I have never had what you describe happen.

this is what I see for this thread with a copy/paste from the URL line.
posting.php?mode=reply&f=47&t=311595

this what I get when I paste the above into Ted.
posting.php?mode=reply&f=47&t=311595

looks the same to me.

this is what I get when I bookmark this thread in FF, and then open Recently bookmarked items, and the copy the link.
posting.php?mode=reply&f=47&t=311595


they all look the same to me.
Linux Mint 19.3 Cinnamon

User avatar
smurphos
Level 15
Level 15
Posts: 5945
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: prefer clean filenames without: "link to"

Post by smurphos »

Pepper-Mint-Patty wrote:
Thu Feb 06, 2020 12:53 pm
On Linux Mint 19.2
just pull the 'lock' in FF adress menu into any folder.

2 Yes you can manually rename the +10s files. But why should this be done by hand, i think we are using a computer...
Hi,

I'm not aware of a way to change the default behaviour of dragging a url to to the Desktop or File Manager but assuming you are still using nemo / cinnamon you can add a custom right click context menu to manually make URL links named as you wish as a Nemo Action

E.g

Image
Image
Image
Result
Image

To add the Nemo Action copy and paste these four commands in full to a terminal window.

Make a scripts subdirectory in the nemo actions directory

Code: Select all

mkdir -p ~/.local/share/nemo/actions/scripts
Create the Nemo Action

Code: Select all

tee ~/.local/share/nemo/actions/add_URL_link_here.nemo_action <<'EOB'
[Nemo Action]
# An action to create a URL link in the current directory
Name=Add _URL Link
Comment=Create a URL in %P
Exec=<scripts/add_URL_link_here.sh %P>
Icon-Name=insert-link-symbolic
Selection=none
Extensions=none;
EOB
Create the associated script

Code: Select all

tee ~/.local/share/nemo/actions/scripts/add_URL_link_here.sh <<'EOB'
#!/bin/bash
#Set destination directory
DEST="$1"
if [ -z "$DEST" ]; then
  exit 1; 
fi
#Confirm name of link
NAME=$(zenity --entry --width=250 --title "URL Link name" --text="Confirm link name" --entry-text="URL Link to" )
if [ -z "$NAME" ]; then
  exit 1; 
fi
#Confirm URL of link
URL=$(zenity --entry --width=250 --title "URL" --text="Input URL" --entry-text="https://" )
if [ -z "$URL" ]; then
  exit 1; 
fi
#Double check not overwriting an existing file or directory
if [ -e "$DEST/$NAME".desktop ]; then
  notify-send --expire-time=200000 "Error creating URL link. $DEST/$NAME already exists. Try again."
  exit 1
fi
echo -e "[Desktop Entry]\nName=$NAME\nURL=$URL\nComment=\nTerminal=false\nIcon=text-html\nType=Link" > "$DEST/$NAME".desktop
chmod u+x "$DEST/$NAME".desktop
if [ $? = 1 ]; then
    notify-send --expire-time=200000 "Error creating link. Try again."
  exit 1
else
  notify-send --expire-time=200000 "Successfully created link $DEST/$NAME"
  exit 0
fi
EOB
Make the script executable

Code: Select all

chmod +x ~/.local/share/nemo/actions/scripts/add_URL_link_here.sh
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

Thanks for the help so far. But i am looking for a simple, haslefree way to drag url links into folders. No right and left clicking and renaming etc.
I don't like to mention but in Windows this is default and as simple as that.

But in Mint the filename is for example:
Link to Linux Mint Forums - Index page

Opening this file in text editor shows
[Desktop Entry]
Encoding=UTF-8
Name=Link to Linux Mint Forums - Index page
Type=Link
URL=index.php
Icon=text-html

So how to make the filename by default not show the "Link to" text?
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
smurphos
Level 15
Level 15
Posts: 5945
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: prefer clean filenames without: "link to"

Post by smurphos »

Pepper-Mint-Patty wrote:
Sat Feb 08, 2020 8:08 am
So how to make the filename by default not show the "Link to" text?
So the behaviour you want to change is hardcoded in Nemo (Cinnamon) and Caja (Mate) so the only way to change it would be to download the sources, amend and recompile. I'm pretty sure I know what would need to be changed in Nemo, I haven't looked at Caja. Let me know if you want to go there and I will test and post instructions if I can work it out. Obviously need confirmation of which desktop environment you are using.

XFCE/Thunar the behaviour is different - when you drag the link to the desktop or the file manager it pops up a dialogue allowing you to specify the name of the link. tweak the URL, and if you want change the icon prior to creation. The default name does not have Link to, so you can pretty much drag drop and hit enter to confirm the defaults.

If you are not using XFCE, but are trying to make your links in a file manager window rather than on the desktop a workaround would be install Thunar in addition to your regular File Manager and then drag your links into a Thunar Window.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

Very much appreciated!
this comes up: Nemo 4.2.3 lets you organize files and folders, both on your computer and online.
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

hi smurphos, is this the info you needed? Nemo 4.2.3
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
smurphos
Level 15
Level 15
Posts: 5945
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: prefer clean filenames without: "link to"

Post by smurphos »

Pepper-Mint-Patty wrote:
Wed Feb 19, 2020 6:57 am
hi smurphos, is this the info you needed? Nemo 4.2.3
Thanks,

I'll take a look over the weekend.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

Marvellous!
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
Flemur
Level 17
Level 17
Posts: 7978
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: prefer clean filenames without: "link to"

Post by Flemur »

Pepper-Mint-Patty wrote:
Sat Feb 08, 2020 8:08 am
So how to make the filename by default not show the "Link to" text?
When I dragged the lock icon from firefox into pcmanfm, nothing happened (the drag window bounced back).

When I dragged it into thunar, it asked me for the file name, I enter "mint" and get a file named "mint.desktop" with this content:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Link
Name=mint
Comment=
Icon=user-bookmarks
URL=https://forums.linuxmint.com/viewtopic.php?f=47&t=311595
Click to make it look better:
linkname.gif
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

Pepper-Mint-Patty wrote:
Thu Feb 06, 2020 12:53 pm
Yes you can manually rename the +10s files. But why should this be done by hand, i think we are using a computer...
@Flemur Like i said before: too much of a hassle
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
smurphos
Level 15
Level 15
Posts: 5945
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: prefer clean filenames without: "link to"

Post by smurphos »

Hi - so here are the steps to modify Nemo's source code to remove the Link to on drag and dropped links from the browser. The change only applies to Drag and Drop links, not links make via the context menu Make Link option.

For other readers note that some of the commands include a version string specific to the Nemo version - bear that in mind if using this as a guide to modify a different version of Nemo

Open Software Sources from the menu and check to include Source Code Repositories

Open a terminal window and;

1) Make a working directory and enter it

Code: Select all

mkdir -p $HOME/nemo-dnd-mod; cd $HOME/nemo-dnd-mod
2) Download the nemo source code

Code: Select all

apt source nemo
3) Enter the source code subdirectory

Code: Select all

cd nemo-4.2.3+tina
4) Install build dependencies

Code: Select all

apt build-dep nemo
5) Open the file we need to modify in a text editor

Code: Select all

xed $HOME/nemo-dnd-mod/nemo-4.2.3+tina/src/nemo-view-dnd.c
In the text editor search for the line below (it's line 125)

Code: Select all

	link_display_name = g_strdup_printf (_("Link to %s"), link_name);
and change it to

Code: Select all

	link_display_name = g_strdup_printf (_("%s"), link_name);
Save the file and close the text editor.

6) Back in the terminal window now we will rebuild nemo. This step will produce a lot of output and an warning at the end about failing to sign the package. You can safely ignore that.

Code: Select all

apt build
7) Then install the deb packages we've just made.

Code: Select all

cd ..; apt deb *.deb
Close the terminal, log off, log back on and test what you get Dragging and Dropping from the browser.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

hi smurphos, thanks for the effort! Later this week, with some friends help we will install the commands.
Ill come back to you when done.
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

hi smurphos, we finally had time to install youre script. Must say it worked a treat! Delighted with the result! :D

We made a command to clean the existing 100s of links too:
Open terminal in the folder and
sed -i 's/Link to //' *.desktop

The app we needed to install is almost 300mb. (how) can we remove it?
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

User avatar
Flemur
Level 17
Level 17
Posts: 7978
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: prefer clean filenames without: "link to"

Post by Flemur »

Pepper-Mint-Patty wrote:
Tue Mar 10, 2020 2:36 pm
We made a command to clean the existing 100s of links too:
Open terminal in the folder and
sed -i 's/Link to //' *.desktop
When I suggested
Have you tried renaming the files?
did you actually think you had to do it one file at a time?
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?

User avatar
smurphos
Level 15
Level 15
Posts: 5945
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: prefer clean filenames without: "link to"

Post by smurphos »

Pepper-Mint-Patty wrote:
Tue Mar 10, 2020 2:36 pm
The app we needed to install is almost 300mb. (how) can we remove it?
You can delete the working folder we made (that's about 140 MiB) after installation.

Code: Select all

rm -f $HOME/nemo-dnd-mod
If you are talking about removing the build dependencies installed via the apt build-dep nemo command then unless you took note of what was installed at the time, I think the safest way to identify what can be uninstalled again is via reference to your apt logs. Take a look at the log /var/log/apt/history.log and search for the string build-dep. Beware this log file is only ever for the current month. Older logs are in compressed files in /var/log/apt/

On my current install I'd first built nemo back in January but in one of the compressed logs I found this which lists all the packages the command installed. I'd need to manually copy paste the package names to an apt purge and would want to double check the output before confirming the command.

Code: Select all

Start-Date: 2020-01-07  06:45:02
Commandline: apt-get build-dep nemo
Requested-By: steve (1000)
Install: libgirepository1.0-dev:amd64 (1.56.1-1), docbook-to-man:amd64 (1:2.0.0-41, automatic), libnotify-dev:amd64 (0.7.7-3), highlight:amd64 (3.41-1, automatic), libxt-dev:amd64 (1:1.1.5-1), libffi-dev:amd64 (3.2.1-8, automatic), docbook-xsl:amd64 (1.79.1+dfsg-2, automatic), meson:amd64 (0.45.1-2ubuntu0.18.04.1), libxapp-dev:amd64 (1.6.8+tricia), highlight-common:amd64 (3.41-1, automatic), libosp5:amd64 (1.5.2-13ubuntu2, automatic), libgail-3-dev:amd64 (3.22.30-1ubuntu4), gobject-introspection:amd64 (1.56.1-1), libgtk-3-doc:amd64 (3.22.30-1ubuntu4), libexempi-dev:amd64 (2.4.5-2), opensp:amd64 (1.5.2-13ubuntu2, automatic), libxml2-dev:amd64 (2.9.4+dfsg1-6.1ubuntu1.2), libxklavier-dev:amd64 (5.4-3, automatic), python-pkg-resources:amd64 (39.0.1-2, automatic), libglib2.0-doc:amd64 (2.56.4-0ubuntu0.18.04.4), dh-python:amd64 (3.20180325ubuntu2), libgnomekbd-dev:amd64 (3.26.0-3ubuntu0.18.04.1, automatic), gtk-doc-tools:amd64 (1.27-3), ninja-build:amd64 (1.8.2-1, automatic), python-funcsigs:amd64 (1.0.2-4, automatic), libxkbfile-dev:amd64 (1:1.0.9-2, automatic), libexif-dev:amd64 (0.6.21-4), xsltproc:amd64 (1.1.29-5ubuntu0.2, automatic), intltool:amd64 (0.51.0-5ubuntu1), docbook:amd64 (4.5-6, automatic), python-mock:amd64 (2.0.0-3, automatic), python-pbr:amd64 (3.1.1-3ubuntu3, automatic), libcinnamon-desktop-dev:amd64 (4.4.1+tricia)
End-Date: 2020-01-07  06:45:14
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

smurphos wrote:
Wed Mar 11, 2020 2:20 am

You can delete the working folder we made (that's about 140 MiB) after installation.

Code: Select all

rm -f $HOME/nemo-dnd-mod
I assume that will make any new pulled .url get the 'link to' prefix again? :?:

I was pretty much surprised to see the number 260mb passing when installing the build dependencies. Just to get rid of 6 characters. Didn't expect so much power had to be used for such a small correction. :shock:
Uninstalling the huge list is pretty much impossible.

Well in the end i didn't want the name change to get me some more diskspace. :)
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

Pepper-Mint-Patty
Level 3
Level 3
Posts: 145
Joined: Fri Dec 20, 2019 4:54 pm

Re: prefer clean filenames without: "link to"

Post by Pepper-Mint-Patty »

Flemur wrote:
Tue Mar 10, 2020 7:54 pm
When I suggested
Have you tried renaming the files?
did you actually think you had to do it one file at a time?
Well it is a bit too late for that question now. 8)
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3

Post Reply

Return to “Software & Applications”