Skip to content

Instantly share code, notes, and snippets.

@joshuaiz
Last active August 29, 2015 14:15
Show Gist options
  • Save joshuaiz/89698b3b3db42784da3d to your computer and use it in GitHub Desktop.
Save joshuaiz/89698b3b3db42784da3d to your computer and use it in GitHub Desktop.
Copy files and folders from source into current directory
# After struggling with Automator and AppleScript to try to copy a target folder and its contents
# to the current directory, I ended up creating this simple shell script to do just that.
# Every time I get a new web development project I was creating the same folders and subfolders and
# this script does it all in one go. Just create a template (source) folder with everything you need
# in it and then navigate to your target directory in Terminal and run this script by typing cpfolder
# at the command line.
# To install, add this to your ~/.bash_profile and edit [your source] to your preferred source directory
# (remove the brackets). Do not enclose the source directory in quotes. The "." refers to the current directory.
# If you want to include the parent directory as well as contents, omit the trailing slash in your source folder.
# If you have different types of projects with different folders/files, just copy this to a new line,
# rename the function and update your source and you are good to go.
# Example: cpfolder(){ cp -av ~/Sites/_Template/ .; }
cpfolder(){ cp -av [your source] .; }
# From the command line:
# $ cpfolder
# That's it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment