Change ? char from files and directory

Hello,
I must change files and dirs name which contains che "?" char, I try this:

rename 's/?/-/' *.*

nothing, what's the problem?
thanks

Did you try to escape the ? ?

In ls, ? sometimes means various kinds of unprintable characters you wouldn't expect to appear in a filename.

yes, but nothing

---------- Post updated at 06:13 PM ---------- Previous update was at 06:12 PM ----------

it's seems

In that case, you could try a character class, e.g. print :

rename 's/[^[:print:]]/-/' *.*

You can also use the inode to refer to the file without having to match its name. Get the number from ls -li, and use it in find:

$ ls -li

3548035 -rw-r--r-- 1 tyler tyler     52 Oct 20 09:39 a.log

$ find . -xdev -inum 3548035 -exec echo rm '{}' ';'

rm ./a.log

$

Remove the 'echo' once you've tested that it does what you want.

nothing...

---------- Post updated at 09:14 AM ---------- Previous update was at 09:13 AM ----------

I need rename all files with ? char... in this case I don't solve my problem...

Show us the output from the command:

ls -1

(note that the option is the digit one; not the lowercase letter ell). And highlight the ? characters you are trying to replace. And, also show us the output from the command:

"ls" -1|od -bc

so we can see the characters that are being printed as question marks by ls when output is directed to a terminal. (The quotes around the ls are to avoid any aliases that might be in place.)

the first command:

Ricorso Edilpi? Dobbiaco.doc
Ricorso Edilpi?-Quadraccia.doc

second:

0000000 122 151 143 157 162 163 157 040 105 144 151 154 160 151 227 040
          R   i   c   o   r   s   o       E   d   i   l   p   i 227
0000020 104 157 142 142 151 141 143 157 056 144 157 143 012 122 151 143
          D   o   b   b   i   a   c   o   .   d   o   c  \n   R   i   c
0000040 157 162 163 157 040 105 144 151 154 160 151 227 055 121 165 141
          o   r   s   o       E   d   i   l   p   i 227   -   Q   u   a
0000060 144 162 141 143 143 151 141 056 144 157 143 012
          d   r   a   c   c   i   a   .   d   o   c  \n
0000074

Try this:

mv file  $(ls file | tr -d '\227')

this is the result:

 for i in * ; do mv "$i"  $(ls "$i" | tr -d '\227'); done
mv: target 'Dobbiaco.doc' is not a directory
mv: target 'Edilpi-Quadraccia.doc' is not a directory

try this:

 for i in *;do mv "$i"  "$(echo "$i" | tr -d '\227')";done

yes! it's ok now!
now I must this in recursive mode, I've more directory and sub
advice?
thanks

test this:

find . -type f -name "*.doc" | while read -r i;do mv "$i"  "$(echo "$i" | tr -d '\227')";done

thanks to all, it's perfect :wink: