Added g and p flags to cpdir