Article 4T6BF Change all ? in filenames to _

Change all ? in filenames to _

by
Flexico
from LinuxQuestions.org on (#4T6BF)
I'm trying to write a Bash script to get rid of Windows-illegal characters on my external drive since Windows implodes if it finds one. XD In the past I made the following script to change file name extensions:
Code:#!/bin/bash
for f in *.png; do
mv -- "$f" "${f%.png}.jpg"
echo "$f"
done...but my attempts at modifying it to look for a particular character in the middle of a file name have failed. I'm not too familiar with the syntax of it, so I could use some guidance.
Code:for f in *?*; do
#mv -- "$f" "${f%?}_${?%f}"
#echo "$f"
echo "${f%?}_${?%f}"
donelatest?d=yIl2AUoC8zA latest?i=JI1JwIMdjjQ:CWyPvwBgD7g:F7zBnMy latest?i=JI1JwIMdjjQ:CWyPvwBgD7g:V_sGLiP latest?d=qj6IDK7rITs latest?i=JI1JwIMdjjQ:CWyPvwBgD7g:gIN9vFwJI1JwIMdjjQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments