Grab’n’drop

Here’s something annoying: when you have to copy/move some files to another directory, and then cd there yourself. Written scripts to do that faster: grab:

#!/bin/sh

dir=`pwd`

for item in `echo $@`; do
	echo $dir/$item >> ~/tmp/grab
done

And drop:

#!/bin/sh

grabfile=~/tmp/grab
tempfile=~/tmp/grab.tmp

echo "" > $tempfile				# create if missing

for item in `cat ~/tmp/grab`; do
	mv $item . 2> /dev/null
	if [ $? -ne 0 ]; then			# was some trouble
		echo $item >> $tempfile
		echo "Cannot move: $item"
	fi
done

mv $tempfile $grabfile

Also, added a lose script, which merely deletes ~/tmp/grab for now.

Advertisements

2 Comments

  1. Posted December 26, 2012 at 2:06 pm | Permalink | Reply

    Hi. I’ve found this a few years ago and have been using ever since. I’ve made some changes to better handle special cases, it’s pretty stable now. I’d like to distribute it through Arch Linux AUR now, so – what’s the license for this?

    • thandle
      Posted December 26, 2012 at 9:19 pm | Permalink | Reply

      GPL 3. And share your changes! 🙂

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: