Hi,
I am using Linux Mint 19.1 Cinnamon Desktop. I have 3 drive partitions. First one for Linux Mint os and other two for general purpose storage (NTFS Formatted).
In the storage drive every folder I want to use a different icon, this helps me to identify the folder easily. I know that I can change folder icon by right-clicking and then clicking the property. But the problem is here once I format the OS(Just like I did yesterday to upgrade from LM 18.2 to 19.1) all icons are gone.
What I want is to keep the folder icon inside each folder and the folder should automatically apply the icon. In this way, the folder icon will be kept intact even I format the os or copy the folders to an external HDD.
I am a novice Linux user and it will be great if someone helps me.
[SOLVED] - Solution for Folder Icon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[SOLVED] - Solution for Folder Icon
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Solution for Folder Icon
As fas as I'm aware not any of the usual Linux desktop file managers will/can do this out of the box. However, your want coincides with wanting for example folder/folder.jpg or folder/cover.jpg as the icon for a folder containing a media collection.
When I search for that myself I only hit on the outdated https://github.com/flozz/cover-thumbnailer which has been dead since basically 2011. I would not recommend trying to install that but would recommend using it as a starting point if you were to code something up yourself. Which you may need to; it seems KDE may be an exception but am not finding a current cover thumbnailer for any current file manager as used by Mint.
When I search for that myself I only hit on the outdated https://github.com/flozz/cover-thumbnailer which has been dead since basically 2011. I would not recommend trying to install that but would recommend using it as a starting point if you were to code something up yourself. Which you may need to; it seems KDE may be an exception but am not finding a current cover thumbnailer for any current file manager as used by Mint.
Re: Solution for Folder Icon
I have tried the above solution unfortunately, it does not work with nemo.
We can change the directory icon from properties manually one by one. After little bit search, I came to know that custom-icon info is kept as directory meta-data (gio info /directory-path). If I get any solution that will load this meta-data in bulk from a config file that will resolve my problem. In this way, I have to create the config once and then I can load at any time.
We can change the directory icon from properties manually one by one. After little bit search, I came to know that custom-icon info is kept as directory meta-data (gio info /directory-path). If I get any solution that will load this meta-data in bulk from a config file that will resolve my problem. In this way, I have to create the config once and then I can load at any time.
- smurphos
- Level 18
- Posts: 8498
- Joined: Fri Sep 05, 2014 12:18 am
- Location: Irish Brit in Portugal
- Contact:
Re: Solution for Folder Icon
Here is a little bash script that should work in 19.x with nemo to set a custom icon programmatically to a selection of folders. My testing has been limited.rahulkundu4u wrote: ⤴Sun Jan 20, 2019 2:25 pm What I want is to keep the folder icon inside each folder and the folder should automatically apply the icon. In this way, the folder icon will be kept intact even I format the os or copy the folders to an external HDD.
Prerequisite - each folder that you want to have a custom icon should hold the icon you want to apply but they should all have the same name e.g
thisfoldericon.png
. Replace
"/path/of/interest/"
with the directory you actually want to search - e.g "/media/data/"
or whatever.Code: Select all
#!/bin/bash
for F in $(find "/path/of/interest/" -type d); do
if [[ -f "$F"/thisfoldericon.png ]]; then
echo "Applying "$F"/thisfoldericon.png as custom icon to "$F""
gio set "$F" metadata::custom-icon file://"$F"/thisfoldericon.png
fi
done
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Re: Solution for Folder Icon
Wow, this just works. Think you very much @ smurphos
I really like Linux Mint as it is and do not want to change the default things e.g. file browser because of stability. I believe this is a useful feature for many regular desktop users and this small utility should be included in Linux Mint by default.
I really like Linux Mint as it is and do not want to change the default things e.g. file browser because of stability. I believe this is a useful feature for many regular desktop users and this small utility should be included in Linux Mint by default.
Re: [SOLVED] - Solution for Folder Icon
I found one minor issue. The solution does not work where the directory name contains space. I have solved it in the following way.
Code: Select all
#!/bin/bash
OIFS="$IFS";IFS=$'\n';for F in $(find "/path/of/interest/" -type d); do
if [[ -f "$F"/thisfoldericon.png ]]; then
echo "Applying "$F"/thisfoldericon.png as custom icon to "$F""
gio set "$F" metadata::custom-icon file://"$F"/thisfoldericon.png
fi
done;IFS="$OIFS"
- smurphos
- Level 18
- Posts: 8498
- Joined: Fri Sep 05, 2014 12:18 am
- Location: Irish Brit in Portugal
- Contact:
Re: [SOLVED] - Solution for Folder Icon
Thanks for that and the fix. I wonder if there is another workaround? This has got me thinking about methods to backup and restore other metadata (emblems etc)......
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Re: [SOLVED] - Solution for Folder Icon
Generic would be to let find execute the loop body itself, i.e.,
Code: Select all
find "/path/of/interest" -type d -exec /bin/sh -c '[ -r "{}"/thisfoldericon.png ] && echo "..." && echo gio set "{}" ...' \;
Code: Select all
find /path/of/interest/ -type d -print0 | while read -d $'\0' F; do
if [ -r "$F"/thisfoldericon.png ]; then
echo Applying "$F"/thisfoldericon.png as custom icon to "$F"
gio set "$F" metadata::custom-icon file://"$F"/thisfoldericon.png
fi
done