How to get rid of bad chrs?
rikona
rikona at sonic.net
Wed Aug 4 22:29:52 UTC 2021
On Wed, 04 Aug 2021 19:33:43 +0200
Volker Wysk <post at volker-wysk.de> wrote:
> Hi!
>
> Am Sonntag, den 01.08.2021, 13:23 -0700 schrieb rikona:
> > 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 :-)
>
> I haven't read the whole thread, but this may be useful:
>
> find | sort -r | xargs rename '/.../g'
>
> The "-r" ensures that subdirectories come first, so renaming them
> won't mess with the rest of the list of not yet processed paths.
>
> Symbolic links need to be treated specially, since the link target is
> affected. When you just rename a file, then symlinks pointing to that
> file will dangle. You need to look inside the link (at the link
> target), and change it as well.
>
> I've done a quick search and couldn't find a program that does that.
> You possibly have to write a little program. If you somehow had a
> program named "updatesym", then this could be how to call it:
>
> find -type l | xargs updatesym
>
> The program would read the link target, change the unwanted
> characters and either output both, for further processing, or change
> the link by itself (remove the old one and create a new one).
>
> Hope this helps.
Thanks for the suggestion. After seeing all the unexpected/unusual
problems, and having around 2000 dirs and 100K files, it looks too
risky to 'automatically' try to correct a few hundred errors. It'll be
a manual operation done over time.
More information about the ubuntu-users
mailing list