I’m trying to rename files like *%3A*%3A*.xml to ::*.xml.
MODFILE=`echo $1 | tr -s '"%3A"' ':'`
mv $1 "${MODFILE}"
Does the Job as long as i dont have %3A more than once directly consecutive. I searched a lot and found several Scripts to rename just the first occurrence or its only working when i only have one occurrence.
For example this works only with one occurrence:
for files in *%3A*.xml
do
mv "$files" "${files/%3A/:}"
done
Can someone please help me with this? I’m not that comfortable with shellscripting :/
You’re almost there, if you use:
(two slashes instead of one), then all occurrences will be replaced.