Rename folders and merge then

Advanced Renamer forum
#1 : 05/01-23 12:00
Theo
Theo
Posts: 1
I have a lot of files. Example:

Test01
Test02
Test03
Preview01
Preview02
Preview03
Done01
Done02
Done03

I need to split this files into folders creating and separating by first part of the name. Like this:

Test
| - Test01
| - Test02
| - Test03
Preview
| - Preview01
| - Preview02
| - Preview03
Done
| - Done01
| - Done02
| - Done03

Always the first X chars are common that I want to move into a folder. Like an example:
MAP23-01XXXXXX.PNG
MAP23-01XXX.PNG
MAP25-02XXXXXXXX.PNG
MAP25-02XXX.PNG

All I need is to group this files into folders, removing useless variables to crate a folder and insert files correspondent in this folder, like:
MAP23-01
MAP25-02

I already try: Used a script to create and move each file in a folder that has the same name, and than rename a folder to merge, like this:
MAP23-01XXXXXX
- MAP23-01XXXXXX.PNG
MAP23-01XXX
- MAP23-01XXX.PNG
MAP25-02XXXXXXXX
- MAP25-02XXXXXXXX.PNG
MAP25-02XXX
- MAP25-02XXX.PNG

Than, my idea was to rename this folders, leaving inicial X chars and merge then. But... All rename softwares that I tried, dont merge the folder, append a number or gave an error, leaving like this:
MAP23-01
- MAP23-01XXXXXX.PNG
MAP23-01(1)
- MAP23-01XXX.PNG
MAP25-02
- MAP25-02XXXXXXXX.PNG
MAP25-02(1)
- MAP25-02XXX.PNG

The problem is that I have so many files to organize into folders. And I need to organize manually.... I tested move batch mode from advanced renamer, but I fail it.


05/01-23 12:00
#2 : 06/01-23 19:57
David Lee
David Lee
Posts: 1125
What you are asking is not totally clear - it appears that you have two scenarios:

1) Move all files in the list into sub-folders named as the initial non-numeric part of each filename
eg "Test01" is moved into folder "Test"

2) Move all files into sub-folders named as the first N characters of each filename
eg "MAP23-01XXXXXX.PNG" is moved into folder "MAP23-01" (N=8)

I'm assuming that you want to create the sub-folders within the same folder that contained the original files.

The second example will be the easiest - simply select Batch mode: Move and enter Output folder = <Substr:1:N> where N=8 in this particular example

The first example is a bit more tricky and you will have to use Batch mode: Rename with a Script method using the JavaScript match method, with a regular expression, to select the initial string of alphabetic characters. In this case you will need to append the new folder names to the existing path.

The script is simply:

item.newPath = item.path + item.name.match(/[^\d]*/)[0];

You do not need a return statement since you will not be renaming any files.


06/01-23 19:57 - edited 06/01-23 23:17