How to get rid of bad chrs?
Volker Wysk
post at volker-wysk.de
Wed Aug 4 17:33:43 UTC 2021
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.
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20210804/0f2b2676/attachment.sig>
More information about the ubuntu-users
mailing list