On Wed, Jan 19, 2011 at 09:06, Merlin Morgenstern <merli...@fastmail.fm> wrote:
> Hello,
> I am using shell_exec to uncompress zip files which works fine, but has one
> big problem. Whenever the zip-archive containes an already existing file
> name, it will overwrite the current one. I need the file to be extracted and
> autorenamed.
> This is the code line:
>        $output = shell_exec('unzip -jo '.$filename.' -d '.$path);
> Does anybody know a way on how to autorename existing files?

    Just because you're using PHP as a frontend doesn't mean this is a
PHP question.  This is a Linux administration question, and one that
Google can handle.

> I thought about a workaround on extracting to a tmp folder and then moving
> to the proper directory while renaming the files if they already exists.
> Unfortunatelly I could not find a way to do this.

    Probably because you haven't written it yet.  When you think about
how to achieve this, it's really simple:

        1.) Create a temporary directory (e.g. -
mkdir(dirname(__FILE__).'/tmp'.time()) for a unique name).
        2.) Extract the files to that directory.
        3.) Check the target directory for existing files.
        4.) Handle things as appropriate.

    There are even simpler ways, again available by searching Google,
you may just need to adjust your search terms and try again.

</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to