Вопрос

I've uploaded a big number of files including their folder structure to my Ubuntu 12.04 LTS Server using WinSCP. The goal is to access these files in Owncloud.

However, all files that contain special character like German Umlauts cause problems. In Ownclouds view, their name is cut off at the special character and trying to view that folder or file will send you back to the folder root.

Using ls, the special character is always displayed as a question mark, e.g. "Moterschwei?en1.jpg" What works is manually renaming them through "mv" in the shell. Inserting the special char properly, e.g. "Motorschweißen1.jpg" for this example, does work, but doing this for all of them would take ages.

Using find . -name "?" will not yield any hits.

Is there any way to replace all of those special characters, e.g. with an underscore?

Это было полезно?

Решение

Try the command rename:

rename 'y/\W/_' *

The above command will replace all non alphanumeric characters with _. See http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators and http://perldoc.perl.org/perlre.html#Special-Backtracking-Control-Verbs for the documentation of perl regex expression.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top