# 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 this all the time, especially when I download files.I'm “still afraid to use spaces in file names” years old
411–420 of 817 posts
Re: I'm “still afraid to use spaces in file names” years old
#412Earlier quoted context omitted.
If I am not writing all of my installation scripts by hand, because that would be really intense, then every folder gets filled with random bits of software. Offering too many similar choices leads to mess. There's nothing fundamentally different between using one or more of these options and using the only option, except that in the second case there isn't any opportunity to make mess. > You can do `configure --pref…
> then every folder gets filled with random bits of software. What does that even mean? When you install something, you put it where you want it. If you don’t like where your distribution puts files, choose a different one. Not all of them use the same convention.
Re: I'm “still afraid to use spaces in file names” years old
#413I 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…
"Path is not a string - it's a sequence of path components and should be treated as such by our APIs." For maximum correctness, you want to turn it into a file handle as soon as possible, and do all operations through the variations of the file functions that end in "at", like: https://linux.die.net/man/2/openat The downside of this approach is that you still technically have to carry the path around with you if you…
That's not right. You want to resolve a file/folder path to a file/folder at the exact point it makes sense.
It's a problem if you're using a path when you wanted the file. The file can be switched/modified out from underneath you.
It's also a problem if you've got the file when you only wanted a reference. Now you can't simply switch/modify the file independent of the reference. E.g., maybe you want config file changes to take effect immediately and transparently.
You can also have the hybrid case, e.g., where you want the folder directly, but have a relative path to a file that is resolved late.
If you're unsure, I'd err on the side of late resolution.
Re: I'm “still afraid to use spaces in file names” years old
#414Earlier quoted context omitted.
> 2021-01-01 Yes on the date format. Saves you so much time.
Agreed on dates ordering problem but 20210101 is so much easier to type.
Re: I'm “still afraid to use spaces in file names” years old
#415Earlier quoted context omitted.
I wish they did "User Files" instead of "Users" too, because so much software breaks on the home area having a space in it. Not least, it makes writing scripts for various shells and getting the quoting rules right an absolute pain as well...
Huh, spaces. There's way too much software, especially on Windows, that breaks when there are Cyrillic characters in a path. I'll let you guess how I found out.
The double grave I is used by some obscure orthodox religionious texts
Re: I'm “still afraid to use spaces in file names” years old
#416Define " space ". Is the Hangul filler we talked about yesterday a spacing character? Is the zero-width non-breaking space a spacing character? What about the typographic spacing characters? You should better be very afraid of using spaces in filenames. You should do everything you can to support them but you have to know you'll invariably encounter countless cases where you'll have this or that tool that won't work…
> 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?
Re: I'm “still afraid to use spaces in file names” years old
#417Re: I'm “still afraid to use spaces in file names” years old
#418Earlier quoted context omitted.
Long option names are more descriptive, more easily distinguished, and easier to remember. Your shell should be intelligent enough to provide tab completion for option names, assuming it is configured to.
> Long option names are ... easier to remember ... Your shell should be intelligent enough to provide tab completion They are so easy to remember that you need to configure your shell to remember them for you?
Re: I'm “still afraid to use spaces in file names” years old
#419Earlier quoted context omitted.
Wow, thanks for the reply, nice find! I did some poking around on my Linux system and even re-arranging the home folder was a task of its own because the system kept trying to replace folders in their original places. I will do some digging in to Gobo and see how they're handling this. Thanks again for pointing this out.
> the system kept trying to replace folders in their original places. This is the file that you want: $ cat ~/.config/user-dirs.dirs XDG_DESKTOP_DIR="$HOME/" XDG_DOWNLOAD_DIR="$HOME/Downloads" XDG_TEMPLATES_DIR="$HOME/" XDG_PUBLICSHARE_DIR="$HOME/" XDG_DOCUMENTS_DIR="$HOME/" XDG_MUSIC_DIR="$HOME/" XDG_PICTURES_DIR="$HOME/" XDG_VIDEOS_DIR="$HOME/"
Re: I'm “still afraid to use spaces in file names” years old
#420One of the main reasons why Windows used "Program Files" and "Documents and Settings" was to force the programs (and programmers) to deal with paths with spaces. And you know, for the most part it kinda, more or less worked out although of course even today you will find programs that ask you to install them in a folder without spaces in the path.