LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2010, 11:08 PM   #1
touser
Member
 
Registered: Apr 2005
Posts: 31

Rep: Reputation: 15
Convert many files to individual .bz2 files retaining original name?


Hello everyone, i have a large directory of .bsp files that i would like to convert .bz2 archives. I've been searching for some time and all i can find is the obvious compress multiple files into one large archive. If anyone knows how to convert each file individually, while retaining the original file name (testmap.bsp would be archived as testmap.bsp.bz2) Any help is greatly appreciated!
 
Old 03-28-2010, 11:15 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
In the appropriate directory:
Code:
for filname in *.bsp; do
    <command to make a bz2> $filname $filname.bz2
done
 
Old 03-28-2010, 11:16 PM   #3
robertstar20
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Rep: Reputation: 0
What's wrong with:

$ bzip2 large_directory/*

?
 
Old 03-28-2010, 11:21 PM   #4
touser
Member
 
Registered: Apr 2005
Posts: 31

Original Poster
Rep: Reputation: 15
Wow, thank you for the quick response! That was far simpler than i expected, thanks for making me feel stupid haha
 
Old 03-28-2010, 11:27 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by robertstar20 View Post
What's wrong with:

$ bzip2 large_directory/*

?
Nothing----except that it deletes the uncompressed version of the files and chokes when it comes to a directory. It's also "brute force"--ie it blindly converts everything in sight.
 
Old 03-29-2010, 12:58 AM   #6
touser
Member
 
Registered: Apr 2005
Posts: 31

Original Poster
Rep: Reputation: 15
This seems to do the trick without any errors:

Code:
for filname in *.bsp; do
    bzip2 -k $filname
done
I also found that:

Code:
find . -name "*.bsp" | xargs bzip2 -k
also works, although i figure that is going to be more system intensive. Thanks again for the help guys!
 
  


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
LXer: How to convert PDF files to HTML or XML files in openSUSE LXer Syndicated Linux News 0 08-20-2008 08:40 AM
Application to convert MySQL files MYD, MYI, FRM to SQL text files ? SethShannon Linux - Newbie 1 09-28-2007 06:03 PM
Can anyone recommend some good software to convert *.wav files into *mp3 files? Tom "Techno" Earl Linux - Software 4 10-12-2006 04:03 PM
Copy files retaining ownership/permissions stefaandk Linux - Newbie 4 09-07-2006 08:25 PM
How can konqueror view html files in .gz & .bz2 files directly? ailinzhe Linux - Software 5 05-24-2004 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:36 PM.

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