I'm a little bit confused again. Shouldn't the last regex set the packagename from the filename without extension. Shouldn't it be then /(.*)\..*$/
Oh, and as backup for safety I store the original name as comment (if no comment). So I can copy it back.