How to get rid of bad chrs?

Little Girl littlergirl at gmail.com
Mon Aug 2 15:57:27 UTC 2021


Hey there,

rikona wrote:
>Little Girl wrote:

>> This command replaces all instances of lower-case a with
>> lower-case b in the name of every file and sub-folder in the
>> current directory, but  

>Just installed rename and may try this.

Sorry about that. I've been using it for so long that I had forgotten
whether it was a default program or one that had to be added on.

> man page is rather brief, may need to check other docs to understand
> it better.

Yeah, and Stack Exchange has a lot of examples of it in use, too.

>> doesn't affect the contents of any sub-folders:  

>So it is not recursive?

That particular example isn't.

> I didn't see a flag to do that.

Me neither. It would have been nice if they had built that ability
into the command.

> A bit of a problem - I have perhaps 2000 folders in a rather deep
> structure. Too many to do 1 by 1. Given maybe 100K files, this
> whole idea makes me rather nervous. :-) Only a couple hundred bad
> ones - may be safer to do them by hand...

Yes, definitely. Actually, no matter how many you have, it's always
safer to do them manually. In fact, with 2,000 folders, I wouldn't
dare run a command on them to allow it to climb inside of all of them
and do its thing.

Normally, I'd recommend FSlint for this job, but they didn't update
it to work with Python 3, so it's no longer available in the current
Ubuntu releases. That's a shame. It can find duplicates, installed
packages, bad names, name clashes, temp files, bad symlinks, bad IDs,
empty directories, non-stripped binaries, and redundant whitespace.
It's simply magical. With that program, though, you would still need
to make decisions on what to do with each file that's found, but at
least you get a good look at your situation, which is always the
safest way of making structural changes. I had a lot of duplicate
photos and it took me a long time to go through them all to make
certain of what ought to be gotten rid of, but FSlint at least made
the process gentle and safe. I'm about to switch to the latest LTS
and will sorely miss this program. I sure hope they update it.

If you're still looking for a command to recursively rename select
files, there are a number of them, but you'll want to explore them,
research them, and test them very thoroughly on dummy directories
first before ever turning them loose on your system.

I messed around with several commands today and so far all of them
fell over when it came to renaming subdirectories and files. They'd
rename a subdirectory before renaming the files inside of it and then
confuse themselves by not being able to find and rename the files
inside of it because they had changed their path. Now that's just
plain irony. I'll let you know if I come across any that seem to be
rock-solid without confusing themselves.

-- 
Little Girl

There is no spoon.




More information about the ubuntu-users mailing list