Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux rename multiple files that are not in utf-8

I have old samba server files that does not show special characters like ä,ö,ü,õ in file names. They are showed as ? mark. Because of that my clients cannot open those files or folders. They see the files and folders, but their names are blank. In server they are showed like this: T??tunnid.doc for example.

Once I rename them with mv command, then my clients can open the folders and files with no problems.

Does anyone know any script that I can use to rename all the files that have ? mark in them. So they show - instead. I would like to rename the files in specific folder for example /samba/documents/...

like image 547
cr0c Avatar asked Nov 24 '25 13:11

cr0c


1 Answers

You can try to use convmv which rename files changing it character encoding. Usually this symbols ? says about different encoding of filenames and terminal/filesystem/something else. Try to determine which character encoding your files use and run it like this:

convmv -fcp1251 -tutf8 *

You can write simple script or just shell loop to iterate over directories and rename all needed files:

find /full/path -execdir convmv --notest -fcp1251 -tutf8 {} \;

But first be sure you use correct character encoding.

like image 115
JIghtuse Avatar answered Nov 26 '25 09:11

JIghtuse