Page 1 of 2

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

Posted: Mon Aug 04, 2014 8:37 pm
by miauriel
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!

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

Posted: Mon Aug 04, 2014 8:48 pm
by DougieLawson
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.

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

Posted: Mon Aug 04, 2014 8:56 pm
by gkreidl
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).

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

Posted: Mon Aug 04, 2014 8:56 pm
by DirkS
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.

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

Posted: Mon Aug 04, 2014 8:57 pm
by AndrewS
What (server? client?) software are you using to copy files to/from the server?

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

Posted: Mon Aug 04, 2014 9:11 pm
by DougieLawson
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.

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

Posted: Mon Aug 04, 2014 9:14 pm
by AndrewS
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? ;)

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

Posted: Mon Aug 04, 2014 9:35 pm
by DougieLawson
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.

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

Posted: Mon Aug 04, 2014 10:41 pm
by miauriel
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??

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

Posted: Mon Aug 04, 2014 11:03 pm
by DirkS
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, ... ).

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

Posted: Tue Aug 05, 2014 12:08 am
by W. H. Heydt
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.

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

Posted: Tue Aug 05, 2014 12:46 am
by miauriel
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!

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

Posted: Tue Aug 05, 2014 1:59 am
by AndrewS
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)

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

Posted: Tue Aug 05, 2014 4:37 am
by W. H. Heydt
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.).

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

Posted: Tue Aug 05, 2014 6:52 am
by Cancelor
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 :)

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

Posted: Tue Aug 05, 2014 7:50 am
by RaTTuS
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

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

Posted: Tue Aug 05, 2014 11:59 am
by AndrewS
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:

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

Posted: Tue Aug 05, 2014 12:34 pm
by BMS Doug
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.

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

Posted: Tue Aug 05, 2014 12:45 pm
by Ravenous
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...

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

Posted: Tue Aug 05, 2014 1:15 pm
by hansotten
Nothing in Linux should prevent spaces in filenames, except crappy programs.

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

Posted: Tue Aug 05, 2014 2:10 pm
by Joe Schmoe
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.

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

Posted: Tue Aug 05, 2014 2:19 pm
by RaTTuS
having leading - in files names is a crime against humanity ... see also leading / trailing spaces
never create a file called
-rf
... ...

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

Posted: Tue Aug 05, 2014 2:23 pm
by mikerr
yep, here's a great page on the horrors of filenames:
http://www.dwheeler.com/essays/fixing-u ... names.html

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

Posted: Tue Aug 05, 2014 2:24 pm
by piglet
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**

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

Posted: Tue Aug 05, 2014 3:07 pm
by DougieLawson
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.