I need a shell script that basically does this:
Basically its a script to substitute a list of txt files for its zip equivalent but keeping the same name.
I've have used find to find the files that I want to zip:
find . -name '.txt.' -print
The Results are:
./InstructionManager.txt.0
./InstructionManager.txt.1
Those are the files I want to zip individually (of course they will be a lot more), but don't know how to use them as arguments individually for make commans like:
zip ./InstructionManager.txt.0.zip ./InstructionManager.txt.0
mv ./InstructionManager.txt.0.zip ./InstructionManager.txt.0
zip ./InstructionManager.txt.1.zip ./InstructionManager.txt.1
mv ./InstructionManager.txt.1.zip ./InstructionManager.txt.1
Any Ideas? And no, i don't want a zip with all the files :S Thanks
Right-click on the file or folder. Select “Compressed (zipped) folder”. To place multiple files into a zip folder, select all of the files while hitting the Ctrl button. Then, right-click on one of the files, move your cursor over the “Send to” option and select “Compressed (zipped) folder”.
Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
Find and select the files you want to compress in File Explorer, then right-click and choose Send to > Compressed (zipped) folder. A new folder appears next to the original files with a big zipper on it, indicating that it's zipped. The new ZIP file automatically uses the name of the last file you zipped.
Simply select All file types, add . bat after filename, and click the Save button. Now, go to the created batch file and double-click on it to execute the zipping script. It will create an archive folder in the specified location.
find . -name '*.txt.*' -print -exec zip '{}'.zip '{}' \; -exec mv '{}'.zip '{}' \;
.txt
files-exec
zips the files-exec
renames the zipped files to the original namesNote that this procedure overwrites the original files. To be sure that the new files are actual zip files, you can do:
file InstructionManager.txt.*
Which should return:
InstructionManager.txt.0: Zip archive data, at least v1.0 to extract
InstructionManager.txt.1: Zip archive data, at least v1.0 to extract
Using find and zip:
find . -name '*.txt.*' -exec zip '{}.zip' '{}' \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With