Live data from Hacker News

I'm “still afraid to use spaces in file names” years old

twitter.com

611–620 of 817 posts

Re: I'm “still afraid to use spaces in file names” years old

#611
post #76

Earlier quoted context omitted.

I'd argue it's at most a tiny bit harder to read, and a lot easier to type. On balance I'd rather avoid making a pinky key one of the keys I have to use the most.

Having used a lot of all the formats, it's argue it's a lot easier to read an a tiny bit harder to type. For typing it's basically just an extra `-` because unless your alternative is nocase. For reading, CamelCase has 2 significant ambiguity issues: similarity between I and l, and what do you do with acronyms. Acronyms wouldn't actually be a problem if everybody just wrote them would in snake_case (i.e. only capital…

[deleted]

Re: I'm “still afraid to use spaces in file names” years old

#612
post #411

I have an overly-aggressive function in my .bashrc to rename all files in the current directory: # Rename all files in a directory rn() { rename "s/ /-/g" * rename "s/_/-/g" * rename "s/–/-/g" * rename "s/://g" * rename "s/\(//g" * rename "s/\)//g" * rename "s/\[//g" * rename "s/\]//g" * rename 's/"//g' * rename "s/'//g" * rename "s/,//g" * rename "y/A-Z/a-z/" * rename "s/---/--/g" * rename "s/-‎--/--/g" * } I use th…

Nice but how do you prevent overwrites? What about directories/folders and the files in that directory/folder?

I have:

  Movie Bla (2020)
    Movie Bla (2020).mp4
But also:

  Movie_Bla_(2020)
    Movie_Bla_(2020).mp4
    Movie_Bla_(2020).srt
Would not like to lose files like the the srt.

Re: I'm “still afraid to use spaces in file names” years old

#613
post #588

Spaces in file names break half of the shell scripts I have encountered. And it is one of the biggest reason I hate Unix shells as programming languages, it is a minefield. In fact I think that after a dozen lines, Perl is a better option. It has most of what shells are good at (i.e. running commands), but saner and more powerful.

my god, I was simply trying to loop over every file in a dir and zip it in a bash one liner. Of course, some of the inputs had spaces in the file names. What an exercise in frustration!!!

Re: I'm “still afraid to use spaces in file names” years old

#614

Earlier quoted context omitted.

> FWIW, and it should be food for thought, every single Git repository in the world contains a pre-commit hook sample (disabled by default but it's there) that enforces that every committed file in the repo is named using a subset of ASCII characters. I use Git for documents too, not only code. Why shouldn't I use my native language?

Tab completion don’t work well for languages that require IME. That is one reason why I don’t.

Tab completion works just fine for me with a Japanese IME.

Re: I'm “still afraid to use spaces in file names” years old

#616
post #190
post #173

Earlier quoted context omitted.

"Documents and Settings" still exists on Windows 10, as a soft link to "Users".

You know, this makes me wonder.. tangentially speaking- I wonder how hard it would be to rearrange the folder structure in linux so that I have something like this: /Users/{root, user0, user1, ... }... /System/{Logs, Apps/{opt, container, ...}, Temp, Conf ...}... /Devices/{Mount, sda, sdb, null ...}... /Boot/...

Couldn't you do it with plain old symlinks?

Re: I'm “still afraid to use spaces in file names” years old

#617
post #604

I have an uneasy feeling whenever I see a path parameter declared as string. Path is not a string - it's a sequence of path components and should be treated as such by our APIs. A path should be parsed once - on user input - and then used in its "sequence form" throughout the software stack. And "path component" is not an arbitrary string either - e.g. appending a path component to the path should first require conve…

Strings following certain rules are entirely valid representations of paths, just like sequences of path components in the chosen language/framework are. Similarly, the sequences of bits that make up the sequences of your language/framework in memory are an entirely valid representation of said sequences of components. Yes, paths have structure, but saying "a path is not a string" is equivalent of saying "C source co…

C source code and paths are both representable by strings, true, but the fact that they're not actually strings is still important, because most people don't know that, and in the case of paths that leads to a lot of edge cases (in the case of source code it leads to a bunch of inefficient and weak tooling, which isn't quite as bad).

Because neither are strings, their native representation shouldn't be such - it should be something structured, and only when necessary (IPC, FFI, serdes) be serialized into a string representation. This would save people a lot of time and effort.

Re: I'm “still afraid to use spaces in file names” years old

#619

I work on a complex desktop application, and it's been astounding the number of bugs that have appeared over the years triggered by spaces and other unusual characters in file names. If you do anything with subprocesses or path processing, it's absurdly easy to hit in a thousand different ways, over and over again. Pro tip: rename your development directory (or even better: the workspace path in CI) to put a space an…

Seems like MS had the same idea according to an answer in the link: > Microsoft intentionally made programs install to C:\Program Files on Windows 95+ to force programmers to deal with spaces in filenames.

Funny, in the Italian Win9x it is C:\Programmi, which I always thought was more convenient because of the lack of spaces :)

Re: I'm “still afraid to use spaces in file names” years old

#620
post #411

I have an overly-aggressive function in my .bashrc to rename all files in the current directory: # Rename all files in a directory rn() { rename "s/ /-/g" * rename "s/_/-/g" * rename "s/–/-/g" * rename "s/://g" * rename "s/\(//g" * rename "s/\)//g" * rename "s/\[//g" * rename "s/\]//g" * rename 's/"//g' * rename "s/'//g" * rename "s/,//g" * rename "y/A-Z/a-z/" * rename "s/---/--/g" * rename "s/-‎--/--/g" * } I use th…

Thanks to all the comments in this threads, I now have "sudo apt install rename detox" in my install script, and:

    normalize_names() {
        rename "s/-/_/g" *
        detox -s lower *
    }
in my .bashrc.

I've thrown some edge cases at it, and it handles it super well. It deals with consecutive "_", remove leading garbage, normalize unicode, and even prevents naming conflicts by opting out early.

Thanks you.

Post reply on HN