How can I zip up a folder (or tar etc ) (folder contains loads of jpg images) via ssh. Ideally I want each zip to contain 1000 images each. Any idea how I can do this? Thanks.
Here you go, place this code in file and place it in the directory where your images are at: Code: #!/bin/bash # #------------------------------------------------------------------------------ # Script fill create tar.gzs with n number of files in them # just change the num_files variable. # # Place the script into the directory you want to generate the files #------------------------------------------------------------------------------ count=0 file=0 num_files=1000 echo ">>> STart now <<<" for i in `find . -type f`;do if [ "$count" -eq "$num_files" ]; then echo "--- Creating TAR file number $file ---" count=0; file=$(( $(echo $file) +1)); fi count=$(( $(echo $count)+1)); tar czf images.$file.tar.gz $i; done; Code (markup): When you've saved the file just execute chmod +x ./script.sh and then run it with: ./script.sh Once done, you'll have archives : images.0.tar.gz images.1.tar.gz etc in your directory. You can move them to other location by: mv ./images.*.tar.gz /other/location/