diff --git a/mv_here/mv_here.sh b/mv_here/mv_here.sh deleted file mode 100755 index 7d11caa..0000000 --- a/mv_here/mv_here.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ] ; then - exit 1 -fi - -rep=$(dirname "$1") -cible=$(basename "$1") - -cd "$rep" -mv "$cible"/* . -rmdir "$cible" diff --git a/mvparent/README b/mvparent/README new file mode 100644 index 0000000..b6f397e --- /dev/null +++ b/mvparent/README @@ -0,0 +1,13 @@ +mvparent.sh was originally written to be integrated in the ROX-Filer +directory "Send to" menu (and was named mv_here.sh). It moves the +contents of a directory into its parent directory, then deletes the +empty directory. + +To install this script, just copy it in a directory which is in the +PATH, e.g. /usr/local/bin: + cp mvparent.sh /usr/local/bin + +If you want to integrate it in ROX-Filer: + mkdir -p ~/.config/rox.sourceforge.net/SendTo/.inode_directory + cd ~/.config/rox.sourceforge.net/SendTo/.inode_directory + ln -s `which mvparent.sh` "Move here" diff --git a/mvparent/mvparent.sh b/mvparent/mvparent.sh new file mode 100755 index 0000000..02d63ab --- /dev/null +++ b/mvparent/mvparent.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# +# mvparent.sh, Copyright © 2007, 2010 Matteo Cypriani +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What The Fuck You Want +# To Public License, Version 2, as published by Sam Hocevar. See +# http://sam.zoy.org/wtfpl/COPYING for more details. +# +# Moves the contents of the given directory into its parent directory. + +if [ $# -ne 1 -o ! -d "$1" ] ; then + echo "Usage: `basename $0` DIRECTORY" >&2 + exit 1 +fi + +rep=$(dirname "$1") +cible=$(basename "$1") + +if [ "$cible" = "." -o "$cible" = ".." ] ; then + echo "Target cannot end by « . » or « .. »!" >&2 + exit 2 +fi + +echo "Move the contents of « $rep/$cible » into « $rep »…" >&2 + +cd "$rep" +mv "$cible"/* "$cible"/.[!.]* . +rmdir "$cible"