The sub should work, but in this case the argument looks like afolderpath. If you pass a full file name as the argument, theresult should be the folder path...