Avatar script fix for subdirectories