Skip to content

Code examples

Useful Commands


Generate random hexadecimal string

openssl rand -hex 64

Check file hash

Mac:

shasum -a 256 /path/to/file

md5 /path/to/file

Windows:

Certutil -hashfile \path\ SHA256

Format disk & remove any "protected partitions"

  1. run "diskpart" (win + R)
  2. commands:
    list disk
    select disk #
    attributes disk clear readonly
    clean
    create partition primary
    format fs=exFAT
    exit
    

Create folders for each filename and move files into them

WINDOWS:

folders-per-filename.ps1
1
2
3
4
5
6
Get-ChildItem -File | ForEach-Object {
    $folderName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
    $newFolderPath = Join-Path -Path $_.DirectoryName -ChildPath $folderName
    New-Item -ItemType Directory -Path $newFolderPath -Force | Out-Null
    Move-Item -Path $_.FullName -Destination $newFolderPath -Force
}

BASH: