Backgrounds - Recursive Folders [SOLVED]

Questions about applications and software
Forum rules
Before you post please read how to get help
User avatar
smurphos
Level 13
Level 13
Posts: 4628
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Backgrounds - Recursive Folders

Post by smurphos » Sun Oct 20, 2019 6:19 am

This should do it

Code: Select all

find ~/Documents/Test/ -type f -iname "*.*p*g" -exec ln -s "{}" ~/Documents/Test/  \;
In English

Search ~/Documents/Test/ for files -type f that include the non case sensitive -iname pattern "*.*p*g" in their name and for each file found make a symlink -exec ln -s to the file "{}" in ~/Documents/Test/.
Last edited by smurphos on Sun Oct 20, 2019 6:36 am, edited 1 time in total.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Sun Oct 20, 2019 6:30 am

YEEEEESSSSSSS !!!
Thank you !!!! :D
cover2.jpg
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Sun Oct 20, 2019 7:40 am

smurphos wrote:
Sun Oct 20, 2019 6:19 am
This should do it

Code: Select all

find ~/Documents/Test/ -type f -iname "*.*p*g" -exec ln -s "{}" ~/Documents/Test/  \;
In English

Search ~/Documents/Test/ for files -type f that include the non case sensitive -iname pattern "*.*p*g" in their name and for each file found make a symlink -exec ln -s to the file "{}" in ~/Documents/Test/.
The only problem is that I have a lot o photos with the same name.
Is there a way to symlink them directly numbered, like from 0001.jpg to XXXX.jpg ?
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

User avatar
Spearmint2
Level 16
Level 16
Posts: 6878
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: Backgrounds - Recursive Folders

Post by Spearmint2 » Sun Oct 20, 2019 10:17 am

Look at how they did it for the Cosmos folder and files in it. The control file is there, follow that example. Just open file manager to File Folders, and Search for Cosmos.
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Mon Oct 21, 2019 1:16 am

~FLOW~ wrote:
Sun Oct 20, 2019 7:40 am
The only problem is that I have a lot o photos with the same name.
Is there a way to symlink them directly numbered, like from 0001.jpg to XXXX.jpg ?
That complicates things a little but yes. I think you might need to split the command to do jpgs and pngs seperately.

Code: Select all

COUNTER=1; IMAGES=$(find ~/Documents/Test/ -type f -iname "*.jp*g"); for i in $IMAGES; do ln -s "$i" ~/Documents/Test/"$COUNTER".jpg; ((COUNTER++)); done

Code: Select all

COUNTER=1; IMAGES=$(find ~/Documents/Test/ -type f -iname "*.png"); for i in $IMAGES; do ln -s "$i" ~/Documents/Test/"$COUNTER".png; ((COUNTER++)); done
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Mon Oct 21, 2019 1:19 am

Spearmint2 wrote:
Sun Oct 20, 2019 10:17 am
Look at how they did it for the Cosmos folder and files in it. The control file is there, follow that example. Just open file manager to File Folders, and Search for Cosmos.
And you won't find it unless you are running MATE :roll:
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
Spearmint2
Level 16
Level 16
Posts: 6878
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: Backgrounds - Recursive Folders

Post by Spearmint2 » Mon Oct 21, 2019 3:58 am

How to use a slideshow, compliments of Cosmos, found in MATE. You make one similar, use .xml as the file ending, and place in your backgrounds folder, along with the images you want displayed. They all are .jpg images used in this, so not sure if using .png images are OK too. I didn't include the entire file, just enough of the top and bottom so you can see the pattern.

<background>
<starttime>
<year>2019</year>
</starttime>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/cloud.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/cloud.jpg</from>
<to>/usr/share/backgrounds/cosmos/comet.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/whirlpool.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/whirlpool.jpg</from>
<to>/usr/share/backgrounds/cosmos/cloud.jpg</to>
</transition>
</background>
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Mon Oct 21, 2019 4:45 am

Cinnamon doesn't support the XML slideshow format for backgrounds or the screensaver.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
Spearmint2
Level 16
Level 16
Posts: 6878
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: Backgrounds - Recursive Folders

Post by Spearmint2 » Mon Oct 21, 2019 6:02 am

So glad I'm using MATE. The deficiencies I keep hearing about Cinnamon at times, makes me wonder why it's so popular?
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Mon Oct 21, 2019 8:53 am

smurphos wrote:
Mon Oct 21, 2019 1:16 am
~FLOW~ wrote:
Sun Oct 20, 2019 7:40 am
The only problem is that I have a lot o photos with the same name.
Is there a way to symlink them directly numbered, like from 0001.jpg to XXXX.jpg ?
That complicates things a little but yes. I think you might need to split the command to do jpgs and pngs seperately.

Code: Select all

COUNTER=1; IMAGES=$(find ~/Documents/Test/ -type f -iname "*.jp*g"); for i in $IMAGES; do ln -s "$i" ~/Documents/Test/"$COUNTER".jpg; ((COUNTER++)); done

Code: Select all

COUNTER=1; IMAGES=$(find ~/Documents/Test/ -type f -iname "*.png"); for i in $IMAGES; do ln -s "$i" ~/Documents/Test/"$COUNTER".png; ((COUNTER++)); done
I knew I had to use a counter and a for, but had no ideea how to implement that in a line.
I will try that in a couple of hours.
Thank you again !! :D
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Mon Oct 21, 2019 11:25 am

I have tried with the code but :

1. I get a lot of error lines :

Code: Select all

ln: unrecognized option '---'
Try 'ln --help' for more information.
ln: unrecognized option '---'
Try 'ln --help' for more information.
ln: unrecognized option '---'
Try 'ln --help' for more information.
ln: unrecognized option '---'
2. I got 6326 symlinks....I have only 2300 photos :))
I have tried 3 times, so 6326 it's not a random number.
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Mon Oct 21, 2019 12:53 pm

OK the for loop is falling over spaces in the filenames / paths. Let me fix.....

Edit to add - OK try this....

Code: Select all

find ~/Documents/Test/ -type f -iname "*.jp*g" -exec bash -c 'COUNTER=1; for file do ln -s "$file" ~/Documents/Test/"$COUNTER".jpg; ((COUNTER++)); done' bash {} +

Code: Select all

find ~/Documents/Test/ -type f -iname "*.png" -exec bash -c 'COUNTER=1; for file do ln -s "$file" ~/Documents/Test/"$COUNTER".png; ((COUNTER++)); done' bash {} +
By the way - I noted running this repeatedly will confuse the thumbnail cache. Once done I suggest you delete ~/.cache/thumbnails
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Mon Oct 21, 2019 1:41 pm

Spearmint2 wrote:
Mon Oct 21, 2019 6:02 am
So glad I'm using MATE. The deficiencies I keep hearing about Cinnamon at times, makes me wonder why it's so popular?
They are just different. Cinnamon doesn't support XML slideshows, because it doesn't need to - it's got a different background slideshow feature - you just tell it a folder and it uses the content of the folder. MATE doesn't support adding folders to it's equivalent of the Cinnamon's backgrounds settings module at all, although you can select multiple images at a time to add. Better / worse? Nope just different. Use what you prefer but please don't assume a MATE solution will work for all DE's, at least not without being clear that your solution is a MATE solution and may be different on XFCE or Cinnamon. It will confuse people.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Mon Oct 21, 2019 4:31 pm

find ~/Documents/Test/1 -type f -iname "*.jp*g" -exec bash -c 'COUNTER=1; for file do ln -s "$file" ~/Documents/Test/2/"$COUNTER".jpg; ((COUNTER++)); done' bash {} +
1. Should be 2345 jpg symlink files.
2. The command creates 2021 symlinks
3. I get this warnings from 1 to 379 :

Code: Select all

ln: failed to create symbolic link 'Documents/Test/[b]2[/b]/1.jpg': File exists
.
.
.
.
ln: failed to create symbolic link 'Documents/Test/[b]2[/b]/379.jpg': File exists
Also I have tried with 385 files and it work as expected. The same is for 1165 files.
Is mybe "COUNTER" limited ?... :?
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Tue Oct 22, 2019 1:31 am

~FLOW~ wrote:
Mon Oct 21, 2019 4:31 pm
Is mybe "COUNTER" limited ?... :?
LOL, this is interesting - so I tested on my main pictures folder as a source - something like 25000 images. And yes - for reasons I don't really understand the for loop restarts somewhere between a count of 1500 to 2000 every time. I ended up with 1891 links.

So another approach - rather than using a numbered count as a name for the link we can use an image hash - basically a unique name derived by the image content. The only way you'd get duplicates is if the directories being searched contained multiple copies of exactly the same image in different locations. To get an image hash you need to have imagemagick installed.

Code: Select all

apt install imagemagick
The command to populate the links is then this..beware it's a lot lot slower as it's analysing each image as it goes along. On my machine the command processes about 200 to 300 files a minute. I had about 30 or so errors from the identify command - basically indicating that some of my images are corrupt.

Code: Select all

find ~/Documents/Test/ -type f -iname "*.jp*g" -exec bash -c 'NAME=$(identify -format %#\\n "$0"); ln -s "$0" ~/Documents/Test/"$NAME".jpg' {} ';'
As an aside this exposes a reproducible memory leak in Nemo, the first time you open a folder with 25K new image symlinks and the thumbnailer kicks in it will gobble up your RAM and eventually nemo will freeze. If you experience that just run nemo -q in a terminal. It should be fine the next time it is launched. Time for a bug report.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Tue Oct 22, 2019 3:08 pm

that is quite a workaround. It works. It's really really slow, but no freeze for me.
I wonder if this one inserted into a sh file would work. Maybe is missing some libraries ?

Code: Select all

find ~/Documents/Test/1 -type f -iname "*.jp*g" -exec bash -c 'COUNTER=1; for file do ln -s "$file" ~/Documents/Test/2/"$COUNTER".jpg; ((COUNTER++)); done' bash {} +
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Wed Oct 23, 2019 12:52 am

~FLOW~ wrote:
Tue Oct 22, 2019 3:08 pm
that is quite a workaround. It works. It's really really slow, but no freeze for me.
I wonder if this one inserted into a sh file would work. Maybe is missing some libraries ?

Code: Select all

find ~/Documents/Test/1 -type f -iname "*.jp*g" -exec bash -c 'COUNTER=1; for file do ln -s "$file" ~/Documents/Test/2/"$COUNTER".jpg; ((COUNTER++)); done' bash {} +
Having done some reading I think there might be a character limit applied to the commands after the -exec. $file will be huge with 2000+ results from the find command so I think it's probably hitting that character limit, and then restarting the loop with the remaining results. On my test with 25000 ish source images the reset happened more than once. But we needed to use this format with -exec to avoid problems with spaces in filenames... :(
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Wed Oct 23, 2019 8:33 am

I noticed that you cand use
let COUNTER++
https://stackoverflow.com/questions/105 ... ot-working
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

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

Re: Backgrounds - Recursive Folders

Post by smurphos » Wed Oct 23, 2019 1:11 pm

Thanks for the link - that was helpful - the solution is to use a file to store the count rather than a variable.

This one is quick and gives me numbered symlimks from 1.jpg to 24217.jpg when I used my my whole Pictures directory as a source. :D

Code: Select all

echo 0 > /tmp/tempcounter; find ~/Documents/Test/ -type f -iname "*.jp*g" -exec bash -c 'for file do COUNTER=$(cat /tmp/tempcounter); ((COUNTER++)); echo $COUNTER > /tmp/tempcounter; ln -s "$file" ~/Documents/Test/"$COUNTER".jpg; done' bash {} +
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
~FLOW~
Level 2
Level 2
Posts: 82
Joined: Tue Mar 12, 2013 3:23 am

Re: Backgrounds - Recursive Folders

Post by ~FLOW~ » Wed Oct 23, 2019 4:02 pm

smurphos wrote:
Wed Oct 23, 2019 1:11 pm
Thanks for the link - that was helpful - the solution is to use a file to store the count rather than a variable.

This one is quick and gives me numbered symlimks from 1.jpg to 24217.jpg when I used my my whole Pictures directory as a source. :D

Code: Select all

echo 0 > /tmp/tempcounter; find ~/Documents/Test/ -type f -iname "*.jp*g" -exec bash -c 'for file do COUNTER=$(cat /tmp/tempcounter); ((COUNTER++)); echo $COUNTER > /tmp/tempcounter; ln -s "$file" ~/Documents/Test/"$COUNTER".jpg; done' bash {} +
It's workig flawlessly now !!!
Thank you !!
A lot of people will find this thread because a lot of topics are opened on a lot of sites just with this problem, but with no solution.
compassion.jpg
Linux Mint 19.2
Cinnamon 4
Kernel 5

Be patient !!
What seams easy for you now, for a newbie might be a monumental helping hand.
An efficient pack will move as fast as the slowest member.

Post Reply

Return to “Software & Applications”