Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a few directories full of thousands of similar files, most of them redundant, taking up a huge amount of space. There are a few procedures that I'd like to run these files through to reclaim much of this space both by file compression and trimming the redundant files. I think that shell scripts would be the most effective tool for this but I need to know which programs I should be reading about to accomplish it.
Anyway, here are some of the batch procedures I'd like to do to organize this mess:
-Zip all files into individual zips. filename.ext becomes filename.zip with best compression (I hear 7zip makes the most compressed .zips).
-Delete all files whose filenames contain a substring
This has already been answered to my satisfaction - It was handed to me! This alone has reclaimed about a dozen gigs of space! I'd link to the post but I can't include links until I have at least 5 posts so just search under my username if you want the solution.
-Delete all files with filenames that contain substring1 but do not contain substring2
Here's where it starts getting tricky. The filenames are often in the format "Title (additional info)"
-Delete all files with one "additional info" string where another file with the same title with preferable additional info exists. For instance, delete any "Same Title (Revision A).zip" files if "Same Title (Revision B).zip" is found in the directory.
What programs can do this under linux? I think I have some manpages to read.
Here's a mass file zipping script (run from the directory with the files):
for i in *; do zip `basename $i .wmv`.zip $i; done
change the ".wmv" to whatever file extension you're zipping. If you leave out the basename text, you'll get filenames like "file.wmv.zip" instead of "file.zip". also, note those are back quotes (from the ~ key).
For the deleting, can't you just rm *\(Revision\ A\)*.zip. The "\" allows you to use special characters like parenthesis, spaces, etc.
Its always good to understand find, for,.. but for the task of mass renaming, mass moving, mass linking you can try: http://linux.maruhn.com/sec/mmv.html
There should be a downloadable package on every distribution, at least on Debian there is
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.