LinuxQuestions.org
Review your favorite Linux distribution.
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-29-2010, 12:08 AM   #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-29-2010, 12:15 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

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

Rep: Reputation: 0
What's wrong with:

$ bzip2 large_directory/*

?
 
Old 03-29-2010, 12:21 AM   #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-29-2010, 12:27 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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, 01: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

All times are GMT -5. The time now is 06:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration