LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Change the name on zip files (https://www.linuxquestions.org/questions/linux-server-73/change-the-name-on-zip-files-794087/)

chobong 03-08-2010 08:55 PM

Change the name on zip files
 
Hi All,

I have a question about zip file.
How can I change the name of a folder after the folder is ziped,

Example: I have a 'test' folder, and it includes test1.txt and test2.txt
test/test1.txt
test/test2.txt

After I zip the folder, and then extract, it will be display
test_a/test1_a.txt
test_a/test2_a.txt

Just change names in zip file, not in initial files. Please help me!!
Thank you so much

Mortis1369 03-08-2010 10:28 PM

do you have ownership of the files? if not, the command to change ownership is:
Code:

chown username /location/file.zip
once you have ownership i believe that you should be able to do pretty much anything you want to about the file, it gives you WRX capabilities.

Hope this helps!

bmarx 03-08-2010 11:10 PM

That seems like odd behavior. What commands are you using to zip/unzip the files? Are you unzipping the files in a directory that already has the files in question?

chobong 03-17-2010 04:06 AM

Thanks All :)

I cannot solve this problem... :(
I'm having another solution, and wannna ask everyone.

Now, I have directory structure as below
test/test1/a1
test/test2/a2
test/test3/a3
# zip test.zip test -> when I unzip test.zip , it shows test1,test2,test3
How to I can zip 'test' directory to test.zip, and when I upzip it, it will show a1/a2/a3 ?

Please help me one more!
Thank you so much

blacky_5251 03-17-2010 04:16 AM

Try
Code:

zip -j test.zip test
Also, try
Code:

man zip

chobong 03-17-2010 04:21 AM

Thank you your help, blacky_5251

I forgot to remind one thing, a1,a2,a3 are folders, not file
With -j option, it cannot compress...

blacky_5251 03-17-2010 04:26 AM

The only solution I can think of is to write a script that parses the directory tree to the a1/a2/a3 level and adds each directory to the zip file separately.

michaelk 03-17-2010 07:26 AM

The -r option will recurse paths i.e.
Code:

zip -r test.zip test
All files and subdirectories in test will be included in the zip file.

From your first post it appears that you are extracting the files in the same directory as they were zipped and the extracted files are being renamed. Is there an option that will rename files as posted?

chobong 03-18-2010 02:20 AM

Thanks michaelk,

Option '-r' is not effect in this case :(
I just want to change the path of the output zipped file
Ex: test/test1/a1(initial folder) to test/a1(in test.zip)

I don't understand your question. Can you explain more about this?

michaelk 03-18-2010 02:36 AM

The question was not directed at you.

chrism01 03-18-2010 03:40 AM

AFAIK, you can't change the content of a zip file. If you want a different output path, you'll have to create it before you zip it. Same goes for tar, gzip etc...


All times are GMT -5. The time now is 10:45 PM.