Post by santanu@citytech » Thu Dec 19, 2024 10:09 pm

I have more than 30 folders and 2000 files which have white spaces in many folders and file names. Now it is not possible to edit all of them.
So I need your help on how I can change the coding to show the all images.

Code: Select all

For ex. catalog/dia da mãe/Borboleta 1.jpg
Here is a twist: When running on a local server, the white spaces are converted to %20 and the images are displayed, but this is not happening on the server.

Please help me.


Posts

Joined
Tue Aug 04, 2020 7:18 pm

Post by Cue4cheap » Thu Dec 19, 2024 10:46 pm

santanu@citytech wrote:
Thu Dec 19, 2024 10:09 pm
I have more than 30 folders and 2000 files which have white spaces in many folders and file names. Now it is not possible to edit all of them.
So I need your help on how I can change the coding to show the all images.

Code: Select all

For ex. catalog/dia da mãe/Borboleta 1.jpg
Here is a twist: When running on a local server, the white spaces are converted to %20 and the images are displayed, but this is not happening on the server.

Please help me.
Why isn't it possible? I you are on a flavor of unix (i.e. Linux) it is pretty simple to remove or replace the space in the file name.
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by khnaz35 » Fri Dec 20, 2024 3:22 am

You could do something like

Code: Select all

#!/bin/bash

# Function to replace spaces with %20
replace_spaces() {
    find "$1" -depth -name '* *' | while IFS= read -r f ; do 
        mv -i "$f" "$(dirname "$f")/$(basename "$f"|sed 's/ /%20/g')"
    done
}

# Call the function with the directory path
replace_spaces /path/to/your/directory
Just a idea

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member
Online

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by noramila » Mon Dec 23, 2024 8:40 pm

Hello Everyone,
I have a similar problem. Instead of renaming the files, can we fix this in the code? Like, can the spaces in the file names be changed to %20 automatically when showing the images? This would save a lot of time.
Any ideas?

Newbie

Posts

Joined
Tue Nov 05, 2024 7:18 pm
Location - India

Post by OSWorX » Mon Dec 23, 2024 9:20 pm

noramila wrote:
Mon Dec 23, 2024 8:40 pm
I have a similar problem.
...
Like, can the spaces in the file names be ...
The best option would be: give the images correct names (titles).
Simply and no further solution is needed.

Don't know why it's so hard NOT to use: spaces, Umlauts, special characters.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by IP_CAM » Tue Dec 24, 2024 12:45 am

Well, it's most likely just too much work, to rename image-names .... :laugh: :drunk: :laugh:

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by khnaz35 » Tue Dec 24, 2024 2:17 am

IP_CAM wrote:
Tue Dec 24, 2024 12:45 am
Well, it's most likely just too much work, to rename image-names .... :laugh: :drunk: :laugh:
Probably if someone has 1,000 or more images

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member
Online

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by OSWorX » Tue Dec 24, 2024 4:23 pm

khnaz35 wrote:
Tue Dec 24, 2024 2:17 am
IP_CAM wrote:
Tue Dec 24, 2024 12:45 am
Well, it's most likely just too much work, to rename image-names .... :laugh: :drunk: :laugh:
Probably if someone has 1,000 or more images
Every system (does no matter if Win* or *nix) has tools to rename unlimited images in a batch mode.
But the most important issue is, that users have to learn what is allowed and what not.

*nix is NOT Win*

Nowadays eveyone without any knowledge whats to have websites and webstores.
And then, for every small issue they want to have tools which should do their work.

Of course they can have millions of images, but every one should be renamed the right way prior uploading to a server.

And the problem here is not to display images with correct names, the images have to be stored already with correct names before using them later!

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 14 guests