How to get rid of bad chrs?

rikona rikona at sonic.net
Sun Aug 1 22:43:16 UTC 2021


On Sun, 1 Aug 2021 16:52:29 -0400
Little Girl <littlergirl at gmail.com> wrote:

> Hey there,
> 
> rikona wrote:
> 
> >Just did a backup of new box and got many errors using grsync. Almost
> >all were because of 'bad' chrs in the file name ["?: etc]. Some names
> >have more than 1 bad chr. Is there a way to safely remove just this
> >set of chrs in every file name within a folder/subfolders, and leave
> >the rest of the chrs in the file name intact? (safely = no chance of
> >losing a file :-)  
> 
> Yep, but do test it in a safe place (like a new temporary
> directory that you create with some example offending files in
> it) first.
> 
> 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. man page is rather brief, may
need to check other docs to understand it better.

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

So it is not recursive? I didn't see a flag to do that. 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...

> rename 's/a/b/g' *
> 
> And so on.

Thanks for the info!







More information about the ubuntu-users mailing list