Do you write your own .bat/.sh files to deal with menial everyday tasks on your computer?
If yes, What kind of tasks do they perform?
If no, why won't you make your life easier?
Yes.
>>59995903
Yes. I'm going to dump some of them.#!/bin/bash
day=$(date +%F%R%S%s)
Folder=$1
BACKUPDIR=$2
if [[ $# -ne 2 ]]; then
echo "This script takes in only 2 parameters. Exiting...."
exit 0;
fi
if [[ -d $BACKUPDIR ]]; then
File="$BACKUPDIR/$day.tar.bz2"
elif [[ ! -e $BACKUPDIR ]]; then
mkdir -p $BACKUPDIR
File="$BACKUPDIR/$day.tar.bz2"
elif [[! -d $BACKUPDIR ]]; then
echo "$BACKUPDIR exists but isn't a directory"
exit 0;
fi
if [[ -d "$Folder" ]]; then
tar -cvpjf $File $Folder
find $File* -mtime +7 -exec rm {} \;
elif [[ ! -d $Folder ]]; then
echo "$Folder exists but isn't a directory"
exit 0;
elif [[ ! -e $Folder ]]; then
echo "Invalid directory name"
exit 0;
fi
Works great with cron
>>59996405
Forgot to say that this was my backup script
Here's my youtube-dl script:#!/bin/bash
CURRENT=$PWD
VIDEODIR=$1
FILELOC=$2
INDEX=$3
if [[ $# = 2 ]]; then
if [[ -d $VIDEODIR ]]; then
cd $VIDEODIR
elif [[ ! -d $VIDEODIR ]]; then
echo "$VIDEODIR exists but isn't a directory"
exit 0;
elif [[ ! -e $VIDEODIR ]]; then
mkdir -p $VIDEODIR
cd $VIDEODIR
fi
read -p "Download playlist [1] or individual videos [2]? " answer
if [[ $answer = 1 ]]; then
echo "$(<"$FILELOC")"|xargs youtube-dl -f best -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' -i
cd $CURRENT
elif [[ $answer = 2 ]]; then
echo "$(<"$FILELOC")"|xargs youtube-dl -f best -i
cd $CURRENT
else
echo "Not a valid option. Exiting..."
exit 0;
fi
elif [[ $# = 3 ]]; then
if [[ -d $VIDEODIR ]]; then
cd $VIDEODIR
elif [[ ! -d $VIDEODIR ]]; then
echo "$VIDEODIR exists but isn't a directory"
exit 0;
elif [[ ! -e $VIDEODIR ]]; then
mkdir -p $VIDEODIR
cd $VIDEODIR
fi
read -p "Download playlist [1] or individual videos [2]? " answer
if [[ $answer = 1 ]]; then
echo "$(<"$FILELOC")"|xargs youtube-dl -f best -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' --playlist-start $INDEX -i
cd $CURRENT
elif [[ $answer = 2 ]]; then
echo "$(<"$FILELOC")"|xargs youtube-dl -f best --playlist-start $INDEX -i
cd $CURRENT
else
echo "Not a valid option. Exiting..."
exit 0;
fi
else
echo "This script takes in only 2 or 3 parameters. Exiting...."
exit 0;
fi
>>59996423
And my 4chan image downloader script:#!/bin/bash
CURRENT=$PWD
VIDEODIR=$1
CHANURL=$2
CHAN=$3
if [[ $# -ne 3 ]]; then
echo "This script takes in only 3 parameters. Exiting...."
exit 0;
fi
if [[ -d $VIDEODIR ]]; then
cd $VIDEODIR
elif [[ ! -d $VIDEODIR ]]; then
echo "$VIDEODIR exists but isn't a directory"
exit 0;
elif [[ ! -e $VIDEODIR ]]; then
mkdir -p $VIDEODIR
cd $VIDEODIR
fi
echo "$(<"$CHANURL")" | xargs chandere --chan $3 -d
cd $CURRENT
I like powershell for automating tasks.
>>59995903
just some trivial script to expedite the launching of wine applications mostly.
Like,APP_PATH="/whatevs"
APP_BIN="app.exe"
WINEBIN=wine
export WINEDEBUG=-all
RESOLUTION=1366x768
cd $APP_PATH
xrandr --output monitor1 --mode $RES
$WINE $APP_BIN
xrandr --output monitor1 --mode 1920x1080
>.bat files
Never.
>.sh files
Yes.
I use Windows at home, but fortunately I don't have many menial tasks to do on my personal computer. At work I use Linux. I have .sh scripts to automate some common stubby calls I need to make so I don't have to type them out, that's about it.
>>59996442
Gay
>>59995903
I want to make a windows script to move files from one folder to another every boot, with a whitelist of files that remain. No idea where to start though.
>>59995903
generating passwords for stuff:randpw() { < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; }
sending crap to sprungesprunge() { curl -F 'sprunge=<-' http://sprunge.us }
I have some statusbar crap for dwm:#!/usr/bin/env bash
xset -b # Disable beeps
while true
do
feh --randomize --bg-fill ~/.backgrounds/portrait/*
VOL=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
LOCALTIME=$(date +%Z\=%Y-%m-%dT%H:%M)
IP=$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1)
TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))C"
TASK=$(task list | grep -E '^\ 1')
if acpi -a | grep off-line > /dev/null
then
BAT="Bat. $(acpi -b | awk '{ print $4 " " $5 }' | tr -d ',')"
xsetroot -name "$TASK $IP $BAT $VOL $TEMP $LOCALTIME"
else
xsetroot -name "$TASK $IP $VOL $TEMP $LOCALTIME"
fi
sleep 20s
done &
>see OP image
>remember watching The Love Boat in the late 1970s/early 1980s
GOD DAMMIT, OP, NOW I'M GONNA HAVE THAT FUCKING THEME SONG IN MY HEAD ALL GOD DAMNED DAY, YOU FUCKING BASTARD.
>>59996538
>generating passwords
oh I know the code for thatecho butter
I have this service that monitors changes to a directory:import sys, time, logging, json, socket, handlers
from logging.handlers import SysLogHandler
from watchdog.observers import Observer
threads = []
with open('conf.json') as fp:
_file = json.load(fp)
paths = _file['directories']
event_handlers = _file['handlers']
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
log_handler = SysLogHandler(address='/dev/log')
logging.getLogger().addHandler(log_handler)
observer = Observer()
for x in paths:
target = str(x)
for h in event_handlers:
event_handler = getattr(handlers, h)()
observer.schedule(event_handler, target, recursive=True)
threads.append(observer)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
the handlers in the handlers module have an action for files if they create/update/delete/move. The handlers can include logic like only watching for *.py files.
in this way, If I want to drop some file in a folder, I can have actions taken on the file automatically. Lets say the handler takes a python file i drop into a directory and runs a series of unit tests on it. Sorta handy. If anybody wants to see a handler example I can post.
>>59996580
Sure.
>>59996579
lol i forgot about sprunge
>>59996644
sprunge?
>>59995903
I automate robocopy with batch scripts to do my backups.
I connect my phone and run the sricpt, It saves my camera pics, my contacts, my messenger pics and so on.
Comfy shit
I have a script that launches sopcast with mplayer for certain romanian channels like
./player.sh protv
./player.sh antena3
.player.sh primatv
etc
>>59996656
fucking phone
meant to reply to >>59996538
sprunge is online storage for small, public files geared for cli
>>59996740
What's so interesting about gypsie media?
>>59995903
Yes, i wrote some scripts to do animu-related tasks senpai.
>>59995903
Yes
Mostly dealing with formatting the text in my clipboard
>>59996405
>tar
>no data deduplication
>no version control
pls anon, have a look
https://wiki.archlinux.org/index.php/Synchronization_and_backup_programs
I have various .bat's for youtube-dl. Other than that, no, since Windows has good software.
>>60000559
Huh, thanks for pointing that out anon. I guess I'll use rsync instead of tar.