LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-08-2010, 08:55 PM   #1
chobong
Member
 
Registered: Jan 2010
Posts: 90

Rep: Reputation: 15
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
 
Old 03-08-2010, 10:28 PM   #2
Mortis1369
Member
 
Registered: Feb 2010
Location: Denver, CO
Distribution: Fedora 12, Ubuntu 10.10, Linux Mint 10
Posts: 47

Rep: Reputation: 2
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!
 
Old 03-08-2010, 11:10 PM   #3
bmarx
Member
 
Registered: Dec 2004
Distribution: Slackware, Arch, FreeBSD
Posts: 202

Rep: Reputation: 34
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?
 
Old 03-17-2010, 04:06 AM   #4
chobong
Member
 
Registered: Jan 2010
Posts: 90

Original Poster
Rep: Reputation: 15
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
 
Old 03-17-2010, 04:16 AM   #5
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Try
Code:
zip -j test.zip test
Also, try
Code:
man zip
 
Old 03-17-2010, 04:21 AM   #6
chobong
Member
 
Registered: Jan 2010
Posts: 90

Original Poster
Rep: Reputation: 15
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...
 
Old 03-17-2010, 04:26 AM   #7
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
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.
 
Old 03-17-2010, 07:26 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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?
 
Old 03-18-2010, 02:20 AM   #9
chobong
Member
 
Registered: Jan 2010
Posts: 90

Original Poster
Rep: Reputation: 15
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?
 
Old 03-18-2010, 02:36 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
The question was not directed at you.
 
Old 03-18-2010, 03:40 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to zip several files to several zip with one command? thomas2004ch Linux - Newbie 4 02-08-2010 08:13 AM
zip files cooldudeguy Linux - Software 2 10-24-2004 02:57 AM
*.zip files e1000 Linux - Software 2 12-30-2003 10:40 AM
Zip Files linuxsoundprob Linux - Software 8 08-26-2003 06:34 AM
.zip Files Wynd Linux - Newbie 4 08-01-2001 12:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration