Change substring operations to basename and extname