Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Hi, i'm new to the forum so please forgive me if this thread is in the wrong section.
So, i have these hundred of files i need to be compressed individually into the .zip format and i couldn't find a way to do so using the zip utility on the terminal.
All files have blank spaces in their names and they're all the same filetype, i think this should be taken into account. I could also compress them into the 7z format but i couldn't find how either.
what command are you using to compress just one file? which shell are you using? bash?
do you need to take these files in compressed form to Windows? if not, there are better ways to compress files than ZIP format.
these are PNG image files. they are already compressed. you can recompress them into JPEG format and they will use less space. but, JPEG also loses some image quality so you may not want to do that. i leave my images in the format they come in as that is usually good enough. there are ways to get them a bit smaller, but then i find it inconvenient to use them that way.
I'm using bash in linux mint. I used .png just as an example, the files i have are a bunch of .smc and .nes files and i need them to be compressed in either .zip or .7z to take less space from a SD card.
I tried Sefyir's recommendation changing the command a bit and it worked:
Code:
for i in *smc; do zip "$i".zip "$i"; done
But all the output files now have two extensions, like this:
filename.smc.zip
And i was wondering if it's also possible to remove the .smc from the output .zip filename?
But yeah, I would write a script.
Something like this:
Code:
#!/bin/bash
for i in *.smc *.nes; do
zip "${i%.*}".zip "$i"
done
(not tested; read 'man zip'?)
This didn't work. The terminal shows a ">" and does nothing.
Quote:
Originally Posted by Shadow_7
$ for INPUT in *.png; do OUTPUT=$(echo $INPUT | sed 's/\.png/\.zip/'); echo $INPUT $OUTPUT; done
Replace the echo command with the compression one when you're confident the parameters to the compression utility are correct.
i don't understand how to change this line. I tried changing each echo for "7z a -mx=9" but it throws an error for each file.
I already managed to compress all files to .7z using aforementioned command so i just installed mmv and renamed everything removing the double extensions, thanks everyone.
This didn't work. The terminal shows a ">" and does nothing.
What I actually meant:
Save that text to a file, make it executable, and run it form the command line.
Not really necessary in this case, but more convenient if you use that particular set of commands a lot.
or I'd be more likely to keep the echo and add the other command after it, so if it took a while I'd know what was taking a while. The VAR= sets the VAR, where the $VAR returns the "value" of the VAR. Which doesn't have to be uppercase, I just do that to distinguish between variable and command.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.