24 Dec
2023
24 Dec
'23
00:16
On 12/23/23 08:38, Daniel Bauer wrote:
I have lots of files named like 07X55c_IMG_0155.png where 07X55c is a random text of varable lengths which I want to cut so that the file will be renamed to IMG_0155.png
In my simple-mindedness I just opened mc, selected all the files and typed in the rename dialog replace *IMG* by IMG*
If they are all in one directory, just cd to that directory and do: for fnmame in *IMG*.png; do mv "$fname" "${fname#*_}"; done or if in multiple subdirectories feed a while loop with find: while read -r fname; do mv "$fname" "${fname#*_}"; done < <(find the/path -type f -name "*IMG*.png") -- David C. Rankin, J.D.,P.E.