summarylogtreecommitdiffstats
path: root/vdr-moveto.sh
blob: cd35aa1872de88bed9fd98ac16d3a71c88481bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

# vdr-moveto.sh -- simple script for moving recordings to folders
# Ville Skyttä 2007, Public Domain
#
# The preferred way to use this script is through VDR's recording commands
# menu.  To do that, add entries eg. like these to /etc/vdr/reccmds.conf:
#
# Move to movies: vdr-moveto.sh 00_Movies
# Move to music: vdr-moveto.sh 00_Music

videodir="$(sed -ne 's/^\s*VDR_OPTIONS\s*=.*\(-v\s\+\|--video\(=\|\s\+\)\)\([^[:space:])]*\).*/\3/p' /etc/vdr/vdr)"
[ -n "$videodir" ] || videodir="/var/lib/vdr/video"

to="$videodir/$1"
what="$2"
if [ -z "$what" ] ; then
    echo "Usage: $0 TO-DIR WHAT"
    exit 1
fi

mkdir -p "$to"
dir="$(dirname $what)"
todir="$to/$(basename $dir)"
if [ -d "$todir" ] ; then
    mv -v "$what" "$todir"
    rmdir -v "$dir"
else
    mv -v "$dir" "$to"
fi

touch "$videodir/.update"