How do I move files with the same last 5 digits to another folder?

Hi,
I want to move the last 5 digits of the pdf files in a folder to a separate file.
For example I have files like,
TA123-00000
TK26372345
TA123202200000
I want to move TA123-00000 and TA123202200000 to another file.
How can I do that?
Thanks.

Hi,

Hope the following sample helps you.
In this case, dictionary will help you.

Sample20221215-5.zip (3.2 KB)

This sample use Copy instead of Move for testing. Please replace (enable) it with MoveFile

Regards,

Hi,
I am getting this error

Hi,

The above expression is as the following. Can you check this?

dict = files.GroupBy(Function(f) Strings.Right(System.IO.Path.GetFileNameWithoutExtension(f),5)).ToDictionary(Function(g) g.key,Function(g) g.ToArray)

Regards,

Ok solved thank you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.