Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Currently I'm doing the following command in PHP

exec("zip -j -P pass $zipname $filename");

The thing is the $filename is something like oawigufh.tmp is there any way to have the file in the archive called something like file.txt?

share|improve this question

migrated from stackoverflow.com Oct 5 '12 at 16:29

This question came from our site for professional and enthusiast programmers.

8  
This has nothing to do with PHP or programming at all, but with the zip program. –  Zulakis Oct 5 '12 at 15:50
add comment

2 Answers

up vote 1 down vote accepted

You could do a;

exec("mv $filename file.txt && zip -j -P pass $zipname file.txt");
share|improve this answer
    
I'm trying to avoid doing that as it will overwrite the other file in the directory –  qwertymk Oct 5 '12 at 15:59
    
So you want to keep a copy of all the .tmp files intact, with their old names, and also zip each of them into a different zip archive, but for them all to have the same name in each respective archive? –  lynks Oct 5 '12 at 16:01
    
correct (space). –  qwertymk Oct 5 '12 at 16:05
1  
Yeah that should be an easy one...nothing in the zip man page mentions renaming. If you absolutely must achieve this, you're probably going to have to create a directory (probably using the tmp file name) and do your rename and zip in there. Then cleanup afterwards. I'd be tempted to make this 'work space' a ramdisk to avoid hitting the disks all the time. –  lynks Oct 5 '12 at 16:10
add comment

Try this command in Linux command line, I mean echo result string what you executed in exec() and past it in Linux command line.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.