sharen

A bash script to rename files using its sha256 hash number, no error trapping or anything yet.

#!/usr/bin/bash

function procfile {
	filename=$1
	filesum=$(sha256sum -b $filename)
	filesha=$(echo $filesum | cut -d " " -f1)
	# filesha=${filesum%-*}
	extension="${filename##*.}"
	newfilename=$filesha"."$extension
	mv $filename $newfilename
}

function showhelp {
	echo "sharen or $1, is a program designed to rename a specified file"
	echo "to its sha256 hash as its filename, preserving the file exitension"
	echo
	echo "The syntax"
	echo
	echo "	sharen filename"
	echo "		filename being the name of the file to process."
	echo
}

if [ -f "$1" ]; then
	procfile $1
else
	showhelp $0
fi

Adam Warlock

Photoshop edit of Adam Warlock, from his short tenure in Malibu Comics’ Runeverse. Text bubbled removed, graininess removed, color enhanced and resized.

Java OOP program to repeat a number of “Hello World” or other user defined string.

class helloOBJ
{
    Integer count;
    String Greeting;
    
    helloOBJ() {
        count = 10;
        Greeting = "Hello World.";
    }
    
    void assignGreeting(String s) {
        if(s!="") Greeting = s;
    }
    
    void assignCount(Integer i) {
        if(i>0) count = i;
    }
    
    public void run() {
        for(Integer i=1; i<=count; i++)
        {
            System.out.printf("[%04d] %s\n", i, Greeting);
        }
    }
}

class helloAPP
{
    public static void main(String[] args)
    {

        Integer pramCount = args.length;
        helloOBJ myObj = new helloOBJ();

        try {
            if(pramCount>=1) {
                Integer j = Integer.parseInt( args[0] );
                myObj.assignCount( j );
            }
            if(pramCount>=2)
                myObj.assignGreeting( args[1] );
            myObj.run();
        } catch (Exception e) {
            System.out.println("An error occured, check arguments.");
        }

    }
}

Syntax

helloAPP [count [custom string]]