Output folder based on part of filename

Advanced Renamer forum
#1 : 01/07-20 21:21
Jesper Bing
Posts: 2
I'm trying to move images to subfolders based on their filename.
The images are currently stored in the folder "trips".

Example:

trip-to-malaga-2017-001
trip-to-malaga-2017-002
trip-to-malaga-2017-003

Must be moved to: trips/trip-to-malaga-2017

trip-to-italy-2017-001
trip-to-italy-2017-002
trip-to-italy-2017-003

Must be moved to: trips/trip-to-italy-2017

So, I must remove the last hyphen plus the digits from the filename, but how?

#2 : 01/07-20 23:31
David Lee
Posts: 1125
Use the Move Files Batch mode and set the New Path in a Script method using a Regular Expression.

To create the new folders witin the existing folder enter this code into a Script window.

item.newPath = item.path + item.name.match(/^.*(?=-.*$)/) + "\\";

Noe that you don't need a return statement.
#3 : 02/07-20 18:13
Jesper Bing
Posts: 2
Reply to #2:
Thank you very much.