I need to get the name of the last file that was copied and then increment by one to get the next file. The files follow the pattern DDMM###.TXT where ### will start with 000 and end with 005 for the day. I know I can use substring to get the ###, and then increment by 1, and then used replace to replace the ### with the new incremented "string". I was just wondering if there was a more elegant way to do this.
$value = $filetotransfer.substring(4,3)
$newvalue = ([int]$value+1).ToString('000')
$filetotransfer = $filetotransfer.Replace($value,$newvalue)
Where $filetotransfer can be mmdd000.txt to mmdd005.txt depending on the time of the day.