Skip to content
DragonlordWarlock.com

DragonlordWarlock.com

Home of the Dragonlord Warlock/Norin Nightfire

  • Home
  • About Me
  • Poetry
  • Photos
  • Programming
  • Wallpaper
  • Norin Nightfire
  • Privacy Policy
  • Home
  • sharen

sharen

Posted on 2020-09-192020-09-19 By Administrator
programming, scripting

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

Tags: bash programming sha256

Post navigation

❮ Previous Post: Some new PhotoLab Edits (NSFW)
Next Post: 1440p Wallpaper: Simple Slash ❯

You may also like

javascript
Javascript
2012-11-18
forth
Hello World Gforth (better example)
2007-08-25
downloading
Batch downloading with REXX and WGET
2007-08-15
linux
Converting webp to PNG with a bash script to make life easier.
2014-10-01

Archives

Categories

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Advert

  • Facebook

Copyright © 2025 DragonlordWarlock.com.

Theme: Oceanly News Dark by ScriptsTown