I receive numerous files on a weekly basis which are batch saved into a folder. Before i insert them into a software for processing, i am required to remove the date aspect of the name
the files come in this format: 

```
20082019AAAA

21082019AAAA

```

These files are received (for example) on the same day, and save into the same folder.

I have a simple PowerShell code which removes the date prefix of the name

```
get-childitem *.txt | rename-item -newname { [string]($_.name).substring(8) }

```

However, a problem arises. 

If this code were to delete the first 8 characters from both files, both files would be named `AAAA`

Therefore, upon running, the files end up looking like this: 

```
AAAA

21082019AAAA

```

As you can see, only for one of the files is the date prefix deleted.

How can I modify my code such that upon running it will delete the prefix, and if it finds two files with the same remaining name, it will add an `_2` or something of the sort to the files?

This will really improve efficiency as then I can point to the folder directly for auto processing.

Kind regards

D