Fix substr with shorter name now

Checked for old length of dir