How to get rid of bad chrs?
Little Girl
littlergirl at gmail.com
Sun Aug 1 20:52:29 UTC 2021
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 spaces with underscores in the name of
every file and sub-folder in the current directory, but doesn't
affect the contents of any sub-folders:
rename 's/ /_/g' *
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
doesn't affect the contents of any sub-folders:
rename 's/a/b/g' *
This command replaces all instances of foo with bar in the name of
every file and sub-folder in the current directory, but doesn't
affect the contents of any sub-folders:
rename 's/foo/bar/g' *
And so on.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list