[Linux] Script to remove nzb site url from folder name (Or anything else)

Come up with a useful post-processing script? Share it here!
Post Reply
mollydog
Newbie
Newbie
Posts: 35
Joined: August 26th, 2008, 7:37 am

[Linux] Script to remove nzb site url from folder name (Or anything else)

Post by mollydog »

This will remove [nzbmatrix.com] from downloaded folder names. Its adapted from the useful clam virus scan script so they can be combined into one if you wished.

Hope its useful to someone!

Code: Select all

#! /bin/sh

BASENAME=`basename "$1"`

echo "Path to download is $1"
echo "Directory is $BASENAME"
echo "Stripped would be ${BASENAME%\[nzbmatrix.com\]}"

if [ "$BASENAME"=*\[nzbmatrix.com\]* ]; then
  echo 'Directory name contains [nzbmatrix.com]'
  echo "Renaming directory $BASENAME to ${BASENAME%\[nzbmatrix.com\]}"
  cd "$1"/..
  mv "$BASENAME" "${BASENAME%\[nzbmatrix.com\]}"
  else
  echo '[nzbmatrix.com] not present in title, all is well!'
fi
mollydog
Newbie
Newbie
Posts: 35
Joined: August 26th, 2008, 7:37 am

Re: [Linux] Script to remove nzb site url from folder name (Or anything else)

Post by mollydog »

This is the two combined..

Code: Select all

#! /bin/sh

BASENAME=`basename "$1"`

echo "Path to download is $1"
echo "Directory is $BASENAME"
echo "Stripped would be ${BASENAME%\[nzbmatrix.com\]}"

if [ "$BASENAME"=*\[nzbmatrix.com\]* ]; then
  echo 'Directory name contains [nzbmatrix.com]'
  echo "Renaming directory $BASENAME to ${BASENAME%\[nzbmatrix.com\]}"
  cd "$1"/..
  mv "$BASENAME" "${BASENAME%\[nzbmatrix.com\]}"
  else
  echo '[nzbmatrix.com] not present in title, all is well!'
fi


FORCLAM="${1%\[nzbmatrix.com\]}"
LOGFILE="$FORCLAM/clamscan.log"
NEWBASE=`basename "$FORCLAM"`

echo "Path to scan for viruses is $FORCLAM"
/usr/bin/clamscan -i -l "$LOGFILE" -r "$FORCLAM"

if [ $? -eq 1 ]; then
  cd "$FORCLAM"/..
  mv "$NEWBASE" _INFECTED_"$NEWBASE"
fi
twpux
Newbie
Newbie
Posts: 9
Joined: October 7th, 2008, 11:19 am

Re: [Linux] Script to remove nzb site url from folder name (Or anything else)

Post by twpux »

Thanks, saves me a few minutes  ;D
Post Reply