I have about 80 files in a folder that all follow the same naming structure that I need to rename. If I can delimit by _ and ? then it should break the file name into what I'm looking for. Below is an example of the current file name and new file name. Any suggestions on how to do this? I tried a few tutorials online but none of them worked as expected.
Current file name: abcd_This is my file name.pdf?xyz
New file name: This is my file name.pdf
try this with bash :
for f in *; do g="${f#*_}"; h="${g%\?*}"; echo "$f -> $g -> $h"; done
${var#*motif} delete the minimum motif on the left of var content
${var%motif*} delete the minimum motif on the right of var content
Use backslash before ? because it's a special character under UNIX shells
For maximize motif, use ## or %% instead of # and %.