Skip to content

Instantly share code, notes, and snippets.

View caseyjmorris's full-sized avatar

Casey J. Morris caseyjmorris

View GitHub Profile
ls * | foreach-object { $fold = $_.Name.Replace('[', '`[').Replace(']', '`]'); Compress-Archive -path ".\$($fold)\*" -compressionlevel optimal -DestinationPath ".\$($_.name).zip"; mv ".\$($fold).zip" "$($fold).cbz"
@caseyjmorris
caseyjmorris / alphabetizer.js
Created January 29, 2020 02:50
Given a directory with files at its root, place the files into subfolders with the first letter of the file name.
const fs = require('fs');
const path = require('path');
const yargs = require('yargs');
async function alphabetizeDirectory(directory, whatIf) {
if (!fs.existsSync(directory)) {
throw `${directory} not found`;
}
const files = fs.readdirSync(directory).map(f => path.join(directory, f)).filter(f => !fs.lstatSync(f).isDirectory());
const letters = new Set();
@caseyjmorris
caseyjmorris / tweetbrowse.html
Last active December 16, 2019 02:38
Browse though a dump of tweets
<html>
<head>
<script type="application/javascript">
(function () {
let tweets = null;
let handle = null;
/**
* @param {File} file
*/
@caseyjmorris
caseyjmorris / Get-JunkFolders.ps1
Last active August 29, 2015 14:25
Get folders which are empty, which only contain empty directories, or which contain no files which do not have a specified list of unwanted extensions. Unwanted extensions can be regular expressions (put the char '/' at the beginning and end of the unwanted extension arg to indicate it is a regex)
Param(
[string]$RootDirectory = $(pwd).Path,
[string[]]$UnwantedExtensions
)
$Source = @"
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;