Skip to content

Instantly share code, notes, and snippets.

@vifon
Created September 2, 2012 20:28
Show Gist options
  • Save vifon/3604269 to your computer and use it in GitHub Desktop.
Save vifon/3604269 to your computer and use it in GitHub Desktop.
filebringer
#!/bin/zsh
#########################################################################
# Copyright (C) 2012 Wojciech Siewierski #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
#############################################################################
# NAME #
# filebringer - "Bring me this file. NOW!" #
# #
# SYNOPSIS #
# filebringer -name 'foo*.pdf' #
# #
# DIR=/some/effin/huge/directory filebringer -mmin 10 #
# #
# [ DIR=search_here... \ #
# DESTDIR=...and_place_it_there \ #
# CMD=cp \ #
# VERBOSE=1 ] filebringer <find(1) syntax> #
# #
# DESCRIPTION #
# Runs file(1) on the specified file tree and fetches the matching files. #
# By default the current directory is both DIR and DESTDIR. #
# The fetching method is hardlinking by default (CMD=ln), #
# set the CMD environmental variable to change it. #
#############################################################################
DESTDIR="${DESTDIR:-$PWD}"
if [ -n "$DIR" ]; then
cd "$DIR"
fi
find . $* -exec ${CMD:-ln} ${VERBOSE:+-v} '{}' "$DESTDIR" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment