kRename: Move Last three characters from filename to front

My files are named “YYYMMDD Titels (DIFFERENT LENGTHS!)_(X13_Ynn).ext”

I need the Enn, e.g. Y01, Y02 as first characters.

How to achieve this? Thank you!

You could use bash.

YYYMMDD Titels (DIFFERENT LENGTHS!)(X13_Y01).ext
YYYMMDD Titels (DIFFERENT LENGTHS!)
(X13_Y02).ext

If last part are always equal to _Yxx).ext

for files in *.ext; do
y=$(echo "$files" | sed -e "s/.*_//" | sed -e "s/).*//")
cp "$files" "$y-$files" # If you have a backup, change cp to mv
done

Y01-YYYMMDD Titels (DIFFERENT LENGTHS!)(X13_Y01).ext
Y02-YYYMMDD Titels (DIFFERENT LENGTHS!)
(X13_Y02).ext

In the “4. Filename” tab, choose “Advanced Filename” and:

  • Make sure “File extension starts at:” is set to “Last Dot”
  • Click “Find and Replace” and create the following pattern:
    • Find: (.*_\(.*)_(.*)(\))
    • Replace With: \2_\1\3
    • “Find is a Regular Expression”: checked

This will pull out everything after the underscore within the parentheses, and bring it to the front.

Example results:

Thank you @pg-tips, works perfect!

Thanks @hech, I understood your script but prefer kRename, what I have already in use for other modifications in this case!