Posts

hikvision brand flash drives are garbage do not buy

 hi. I have a low-quality usb ssd drive, hikvision brand. I have engaged with you on this particuilar drive before. When I try copy files to it, it fails quite quickly. I remember that f3 (fighting flash fraud) software can check a drive for integrity (hardware). I also believe there are ways to mark and deallocate bad blocks. Please give me a script to do this, asssumiing bash ubuntu linux 24 and that it must pre-install any apt-get packages needed when it runs Below is a single self-contained bash script that: Installs required tools ( f3 , e2fsprogs , smartmontools where applicable) Destructively tests the USB SSD with f3 (integrity / fake-capacity check) Optionally recreates the filesystem and marks bad blocks (only works reliably for ext4) ⚠️ WARNING : THIS WILL ERASE ALL DATA ON THE DRIVE. usb_ssd_check_and_repair.sh #!/usr/bin/env bash set -e if [ " $EUID " -ne 0 ]; then echo "Run as root." exit 1 fi DEV= " $1 " ...

setup google drive and dropbox as automounts on linux

 #!/bin/bash set -e # mount points mkdir -p "$HOME/DropboxMount" mkdir -p "$HOME/GDriveMount" # ensure systemd user dir exists mkdir -p "$HOME/.config/systemd/user" # Dropbox service cat > "$HOME/.config/systemd/user/rclone-dropbox.service" <<'EOF' [Unit] Description=Mount Dropbox via rclone After=network-online.target [Service] Type=simple ExecStartPre=/bin/mkdir -p %h/DropboxMount ExecStart=/usr/bin/rclone mount dropbox: %h/DropboxMount --vfs-cache-mode writes ExecStop=/bin/fusermount -u %h/DropboxMount Restart=on-failure [Install] WantedBy=default.target EOF # Google Drive service cat > "$HOME/.config/systemd/user/rclone-gdrive.service" <<'EOF' [Unit] Description=Mount Google Drive via rclone After=network-online.target [Service] Type=simple ExecStartPre=/bin/mkdir -p %h/GDriveMount ExecStart=/usr/bin/rclone mount gdrive: %h/GDriveMount --vfs-cache-mode writes ExecStop=/bin/fusermount -u %h/GDriveMou...

convert any annoying media format into a standard media format

 #!/bin/bash # mediaconvert – auto-convert any media file with progress bar infile="$1" [ -z "$infile" ] && { echo "Usage: mediaconvert <file>"; exit 1; } ext="${infile##*.}" base="${infile%.*}" case "$ext" in     avi|mov|mkv|webm|flv|mpg|mpeg|mp4)         outfile="${base}.mp4"         pv "$infile" | ffmpeg -y -i - -c:v libx264 -c:a aac -strict -2 "$outfile"         ;;     mp3|m4a|ogg|wav|flac|aac|webm)         outfile="${base}.mp3"         pv "$infile" | ffmpeg -y -i - -acodec libmp3lame -q:a 2 "$outfile"         ;;     jpg|jpeg|png|bmp|gif|tiff|webp)         outfile="${base}.jpg"         pv "$infile" | ffmpeg -y -i - -q:v 2 "$outfile"         ;;     *)         echo "Unsupported file type: $ext"         exit 1 ...

turn image folder into a single pdf

 #!/usr/bin/env bash # Usage: imagefolder_to_pdf.sh /path/to/folder # Creates folder.pdf from all images (JPG/PNG/etc) in that folder at 150 dpi. set -euo pipefail if [ "${1:-}" = "-h" ] || [ "$#" -lt 1 ]; then   echo "Usage: $(basename "$0") /path/to/folder" >&2   exit 1 fi indir="$1" # Strip trailing slash, then append .pdf foldername="$(basename "${indir%/}")" outfile="$(dirname "$indir")/${foldername}.pdf" if [ ! -d "$indir" ]; then   echo "Error: folder not found: $indir" >&2   exit 2 fi # Gather images mapfile -d '' files < <(   find "$indir" -maxdepth 1 -type f \     \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.tif' -o -iname '*.tiff' -o -iname '*.bmp' -o -iname '*.webp' \) \     -print0 | sort -z -V ) if [ "${#files[@]}" -eq 0 ]; then ...

rotate pdf pages of bitmap scan pdfs any degrees

 #!/bin/bash # usage: pdfrotate.sh <angle> <file.pdf> # Rotates all pages of a PDF using pdftk (for 90° increments) or Ghostscript otherwise. angle=$1 file=$2 if [ -z "$angle" ] || [ -z "$file" ]; then     echo "Usage: $0 <angle> <file.pdf>"     exit 1 fi base="${file%.pdf}" out="${base}_rotated_${angle}.pdf" # Round angle if needed norm_angle=$((angle % 360)) # Handle pdftk for standard rotations if [[ "$norm_angle" == "90" || "$norm_angle" == "180" || "$norm_angle" == "270" || "$norm_angle" == "0" ]]; then     case $norm_angle in         0)   dir="north" ;;   # no rotation         90)  dir="right" ;;         180) dir="down" ;;         270) dir="left" ;;     esac     echo "Rotating with pdftk ($norm_angle°)..."     pdftk "$file" cat 1-end${dir} output "$out" else  ...

transcribe a folder of m4a files to text

 #!/bin/bash # convert_and_transcribe.sh # 1. Rename spaces to underscores for f in *\ *; do mv "$f" "${f// /_}"; done # 2. Convert all .m4a files to .mp3 for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 192k "${f%.m4a}.mp3"; done # 3. Move original .m4a files to Trash mv *.m4a ~/.local/share/Trash/files/ 2>/dev/null # 4. Transcribe all .mp3 files using Whisper for f in *.mp3; do whisper "$f" --model medium --language en --output_format txt --output_dir . --fp16 False; done

get rid of all weird characters in filenames

#!/usr/bin/env bash # rename_youtube_clean.sh for f in *; do   [ -f "$f" ] || continue   case "$f" in *.sh) continue;; esac   new="$(printf '%s' "$f" |     tr -cd '\0-\177' |     sed -E '       s/\([^)]*\)//g;            # drop (...)       s/\[[^]]*\]//g;            # drop [...]       s/[⧸||]/_/g;              # strip slashes/pipes       s/[–—]/-/g;                # normalise dashes       s/  +/ /g;                 # squeeze spaces       s/^ +//; s/ +$//;          # trim       s/ - /-/g;                 # tighten hyphen       s/ /_/g;              ...