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.zip $fname*; done
Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: