Created
September 28, 2020 01:59
-
-
Save UVLabs/ce66307ad24234dd55ecfaebb24e70cf to your computer and use it in GitHub Desktop.
Bash script to copy files into a folder and then zip up that folder automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a simple script that copies files and directories to a folder, and then zips up that folder. | |
# You can think of it as sort of a low level deployment script, at least thats what I use it for; | |
# To quickly create a zip using only the files needed for the production version of a WordPress plugin which I then upload to CodeCanyon. | |
# Feel free to extend and modify for your particular use-case. | |
# Instructions: | |
# From your command line, navigate to location of script and then execute it using command: | |
# sh prepare.sh | |
# Completely remove our previously generated zip (just cause) | |
rm -f dist/plugin.zip | |
# Create our base "dist" folder | |
mkdir -p dist | |
# Create our folder for storing the files and directories we want zipped | |
mkdir -p dist/plugin | |
# Trailing . is important if you want to copy all files and subdirectories in "folder1" | |
cp -r /path/to/folder1/. /path/to/dist/plugin/folder1 | |
cp -r /path/to/plugin.php /path/to/dist/plugin/plugin.php | |
# ... | |
# ... | |
# Below is an example if you have spaces in your paths. You need to enclose it in single quotes. | |
# cp -r '/path/to/Bad Naming/folder1/.' '/path/to/Bad Naming/dist/plugin/folder1' | |
# cp -r '/path/to/Bad Naming/index.php' '/path/to/Bad Naming/dist/plugin/index.php' | |
# Create our zip file from the folder "plugin" and name it "plugin.zip" | |
(cd dist/plugin && zip -r ../plugin.zip .) | |
# Show some info about file | |
ls -l dist/plugin.zip | |
# Clean up dist folder | |
rm -r dist/plugin | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment