Zipping shapefiles using Bash

Using bash, the following command will get the shapefile name for each .shp in a folder, strip the shp at the end of the name, and then zip all the shapefile component files into a zip archive in the zips sub-directory.


for file in *.shp; do ext=${file##*.}; fname=`basename $file $ext`; zip zips/$ $fname*; done

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A Website.

Up ↑

%d bloggers like this: