miauriel
Posts: 12
Joined: Mon Jul 21, 2014 1:36 am

RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 8:37 pm

good day

I am using my B+ as a linux home file server, and every file I copy to the server is being renamed automatically. For example, if the file is named "my favorite movie.avi", when I copy it over it turns to "my%20favorite%20movie.avi".

Is there any way I can stop this renaming from occurring

Thanks!

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 8:48 pm

Simple answer: don't put spaces in file names use something benign like an underscore.

More complex answer: URLs/URIs with special characters get encoded so that the special characters aren't sent over the network. Spaces count as special characters so get encoded to %20. http://en.wikipedia.org/wiki/Percent-encoding there's no easy way to avoid it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 8:56 pm

miauriel wrote:good day

I am using my B+ as a linux home file server, and every file I copy to the server is being renamed automatically. For example, if the file is named "my favorite movie.avi", when I copy it over it turns to "my%20favorite%20movie.avi".

Is there any way I can stop this renaming from occurring
Thanks!
How do you copy the files to your "home server". There are lots of ways to keep the spaces (Dougie prefers to live in the stone age of computing, when spaces were not allowed).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 8:56 pm

DougieLawson wrote:More complex answer
I'm fairly sure there's an even more complex answer as (or maybe a simpler answer). I for one don't have any problems with spaces being converted when I move files to my Pi server...

Gr.
Dirk.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 8:57 pm

What (server? client?) software are you using to copy files to/from the server?

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 9:11 pm

DirkS wrote:
DougieLawson wrote:More complex answer
I'm fairly sure there's an even more complex answer as (or maybe a simpler answer). I for one don't have any problems with spaces being converted when I move files to my Pi server...

Gr.
Dirk.
When you've lived with these rules for 34 years: dataset names should be 44 characters (or fewer). The segments of a dataset name can be no more than 8 characters, must start with an alpha or national and are separated by full stops. The valid chars are upper case alpha, numbers and three national characters it becomes a habit to dislike names that don't match that pattern.

I don't need spaces in my Unix file names, so I don't use spaces in my Unix file names.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 9:14 pm

DougieLawson wrote:The segments of a dataset name can be no more than 8 characters, must start with an alpha or national and are separated by full stops.
AUTOEXEC.BAT style? ;)

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 9:35 pm

AndrewS wrote:
DougieLawson wrote:The segments of a dataset name can be no more than 8 characters, must start with an alpha or national and are separated by full stops.
AUTOEXEC.BAT style? ;)
NO, 8.3 sucks and is an artefact of the Fisher Price range of toy computers with less than 640K of memory that appeared in the 1980s.

My habit is from IBM's S/360 MFT / MVT & S/370 MVS (also know a proper mainframe computers[1]). The problem was that the dataset name and some flag bits and bytes had to fit in an 80 byte record. It's even worse with tape datasets, only the last seventeen characters get written to the machine readable tape labels on the first few feet of tape.

[1] The distinction being never trust a computer you can lift.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

miauriel
Posts: 12
Joined: Mon Jul 21, 2014 1:36 am

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 10:41 pm

I normally use an underscore to indicate a space in a file name. However, trying to convince others on my home network to go the extra mile when collating information is like talking to a wall. Moreover, I am also using my B+ as a torrent box running Transmission and the files I download already have spaces in the name which are turned into %20's.

At this time I am backing up data onto the 1TB HDD connected to my pi from other devices, and will eventually be connecting another 1TB HDD to be a redundant timed backup. So with a very large amount of files that have already been named, I want to try and avoid renaming everything prior to putting it on my PiServer.

I am running raspian on the B+, LXLE on my laptop, Win8 (puke) on my wife's laptop, and a WDTVLIVE hub (linux I believe). Although I try and SSH into my pi to transfer files from the command line, I also use my laptop to transfer files.

is there anything I can do??

DirkS
Posts: 10362
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: RPi keeps replacing spaces in file names with "%20"

Mon Aug 04, 2014 11:03 pm

What networking software do you use (server / client side)? Samba, NFS, any other?

Not sure if it's relevant, but maybe also useful to know the file system of the PiServer drive (ext4, NTFS, ... ).

W. H. Heydt
Posts: 12646
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 12:08 am

As exercises for the readers...

1. Try manipulating files with embedded spaces in the file names in a command line environment.

2. Now do it in a scripting language.

The results of doing this in an "obvious" way may not produce the results you think they will.

miauriel
Posts: 12
Joined: Mon Jul 21, 2014 1:36 am

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 12:46 am

I'm using samba, and the TB HDD is ntfs. @ W. H. Heydt: please elaborate on what you mean by manipulating in the command line and scripting.

Thanks!

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 1:59 am

Are you just copying the files to/from the Pi using regular old Windows Explorer then? As Dougie already mentioned, "%20" is the URI-encoding for a space character, so it's what I'd expect to (perhaps) see if you were using some kind of web or http access to your Pi. But AFAIK Samba should be totally fine with filenames containing spaces :?

Ahh, perhaps this is the bug you're seeing? https://bugs.launchpad.net/ubuntu/+sour ... ug/1325270 (which indicates it's a bug in the pcmanfm file-manager rather than in samba itself)

W. H. Heydt
Posts: 12646
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 4:37 am

miauriel wrote:I'm using samba, and the TB HDD is ntfs. @ W. H. Heydt: please elaborate on what you mean by manipulating in the command line and scripting.

Thanks!
Move, copy, rename, concatenate, delete, sort, compare, and so on files with spaces in the file names using a CLI and the doing the same sorts of things using a .bat file or shell script (sh, csh, bash, etc.).

User avatar
Cancelor
Posts: 776
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 6:52 am

DougieLawson wrote:
AndrewS wrote:
DougieLawson wrote:The segments of a dataset name can be no more than 8 characters, must start with an alpha or national and are separated by full stops.
AUTOEXEC.BAT style? ;)
NO, 8.3 sucks and is an artefact of the Fisher Price range of toy computers with less than 640K of memory that appeared in the 1980s.

My habit is from IBM's S/360 MFT / MVT & S/370 MVS (also know a proper mainframe computers[1]). The problem was that the dataset name and some flag bits and bytes had to fit in an 80 byte record. It's even worse with tape datasets, only the last seventeen characters get written to the machine readable tape labels on the first few feet of tape.

[1] The distinction being never trust a computer you can lift.
Yeh, if it doesn't fill a room it's not worth having ;-)

I guess it all dates back to when cards were used to enter data and programmes. http://en.wikipedia.org/wiki/Punched_ca ... cter_codes I used to submit my Fortran code using them :)
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 7:50 am

miauriel wrote:I normally use an underscore to indicate a space in a file name. However, trying to convince others on my home network to go the extra mile when collating information is like talking to a wall. Moreover, I am also using my B+ as a torrent box running Transmission and the files I download already have spaces in the name which are turned into %20's.

At this time I am backing up data onto the 1TB HDD connected to my pi from other devices, and will eventually be connecting another 1TB HDD to be a redundant timed backup. So with a very large amount of files that have already been named, I want to try and avoid renaming everything prior to putting it on my PiServer.

I am running raspian on the B+, LXLE on my laptop, Win8 (puke) on my wife's laptop, and a WDTVLIVE hub (linux I believe). Although I try and SSH into my pi to transfer files from the command line, I also use my laptop to transfer files.

is there anything I can do??
yes lots ...
organise your data in sensible locations
always use the same name conventions
be consistent

what is it that is displaying the %20% instead of spaces ?
the CLI , windows , explorer , etc

then use the same method to copy and only one way i.e.
automagically use
rsync to put them where you want and need
never copy by hand or windows if you can help it
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 11:59 am

Cancelor wrote:Yeh, if it doesn't fill a room it's not worth having ;-)
You must use your Pi in a very small room then? :lol:

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 12:34 pm

AndrewS wrote:
Cancelor wrote:Yeh, if it doesn't fill a room it's not worth having ;-)
You must use your Pi in a very small room then? :lol:
That's why I have a doll's house. well actually it's because I have daughters.
Doug.
Building Management Systems Engineer.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 12:45 pm

BMS Doug wrote: That's why I have a doll's house.
"Barbie's server farm" accessories...

Barbie forecasts her own weather...

Barbie breaks the record for cryptographic number crunching...

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 1:15 pm

Nothing in Linux should prevent spaces in filenames, except crappy programs.
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 2:10 pm

Move, copy, rename, concatenate, delete, sort, compare, and so on files with spaces in the file names using a CLI and the doing the same sorts of things using a .bat file or shell script (sh, csh, bash, etc.).
Leaving Windows (ref: your mention of .bat files) aside (and what else is one to do with Windows?), when writing Unix/Linux shell scripts in an eh-derived shells (and, leaving csh and csh-derived shells aside - and, seriously, what else is one to do with csh/tcsh as a scripting language?), you are usual entirely OK as long as you quote every variable reference. That is, you just get in the habit of never writing:

Code: Select all

echo $foo
and always writing:

Code: Select all

echo "$foo"
As long as you do that, you should be OK, as long as these two things don't happen:

1) Files with newlines in them. This is truly deranged and you can put me down on the list of people who think that spaces in filenames are OK nowadays, but newline is truly sick. Against this, for all I know, quoting does make files-with-newlines work OK; I've never had occasion to test this in my work.

2) Scripts/functions that call other scripts/functions passing parameters on. This has caught me in the past, where you essentially have to "double-quote" things in order to protect them against both the current shell and the sub-shell. This can, obviously, get ugly if you have to support infinite levels of sub-shell-ing.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 2:19 pm

having leading - in files names is a crime against humanity ... see also leading / trailing spaces
never create a file called
-rf
... ...
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

mikerr
Posts: 2825
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 2:23 pm

yep, here's a great page on the horrors of filenames:
http://www.dwheeler.com/essays/fixing-u ... names.html
Android app - Raspi Card Imager - download and image SD cards - No PC required !

User avatar
piglet
Posts: 915
Joined: Sat Aug 27, 2011 1:16 pm

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 2:24 pm

hansotten wrote:Nothing in Linux should prevent spaces in filenames, except crappy programs.
and common sense...

btw I still like GDG's. **pines for mainframe days when programmers had a clue**

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RPi keeps replacing spaces in file names with "%20"

Tue Aug 05, 2014 3:07 pm

piglet wrote:
hansotten wrote:Nothing in Linux should prevent spaces in filenames, except crappy programs.
and common sense...

btw I still like GDG's. **pines for mainframe days when programmers had a clue**
+1 Generation data groups are so much easier than having stupid date/time stamps in dataset names.

He's not a dead dinosaur, he's pining for the mainframe.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “General discussion”