Button to move files to folders, based on part filename..?

Hey guys,

I've been reading through these threads:


[url]Creating folders from filename]

[url]RegExp basics: Removing characters from start/end of names]

Trying to come up with a code which suits my needs... The idea is to take the 1 or 2 alpha characters from the middle of a file name, and move the files to folders based on these 1 or 2 alpha charachers.

For example, we have a collection of files such as:

  • 1068-B1001.dwg
  • 1068-B1002.dwg
  • 1068-B1003.dwg
  • 1068-DD1001.dwg
  • 1068-DD1002.dwg
  • 1068-DD1003.dwg
    ... and so on.

I would like to move these files into folders named only after the bold characters in the above list.

Ive been playing with some code, but I am really struggling to understand the REGEXP syntax.

My current code:

Rename PATTERN "(.*)-(^\w)([0-9]{4}).dwg" TO "\2\\\0" REGEXP

...Does nothing haha.

Just wondering if someone can please point out where I am going wrong, and set me straight.

Thanks a lot for any help.


Our files are actually named like:

  • 1068-B1001_0.dwg
  • 1068-B1002_0.dwg
  • 1068-B1003_1.dwg
  • 1068-DD1001_0.dwg
  • 1068-DD1002_0.dwg
  • 1068-DD1003_2.dwg
  • 1068-DD1004_0.dwg
  • 1068-DD1005_1.dwg

I forgot the _suffix.

Thanks again.

After playing around a bit in the "Rename" dialogue box, I have come up with the following:

Rename PATTERN "(.*)-([^0-9]*)[0-9]{4}_[0-9*].dwg" TO "\2\\\0" REGEXP

Which seems to work pretty OK so far.

Happy to hear some feedback though haha.