Skip to content

Instantly share code, notes, and snippets.

@SteveH3032
SteveH3032 / ps-rename-and-organize-media.ps1
Created November 25, 2018 03:16
PowerShell Rename and Organize Media Files
cd "C:\path\to\media"
# Rename Media based on the 'CreationTime'
Get-ChildItem *.jpg -Recurse | Rename-Item -newname {$_.CreationTime.toString("yyyyMMdd_HHmmss") + $_.Extension} -ErrorAction SilentlyContinue
Get-ChildItem *.jpeg -Recurse | Rename-Item -newname {$_.CreationTime.toString("yyyyMMdd_HHmmss") + $_.Extension} -ErrorAction SilentlyContinue
Get-ChildItem *.png -Recurse | Rename-Item -newname {$_.CreationTime.toString("yyyyMMdd_HHmmss") + $_.Extension} -ErrorAction SilentlyContinue
Get-ChildItem *.mp4 -Recurse | Rename-Item -newname {$_.CreationTime.toString("yyyyMMdd_HHmmss") + $_.Extension} -ErrorAction SilentlyContinue
Get-ChildItem *.jpg, *.jpeg, *.png, *.mp4 -Recurse -ErrorAction SilentlyContinue | ForEach-Object -process {
# Set Output Folder Based on File Type
@SteveH3032
SteveH3032 / cSharpNuGetDownloader.cs
Created November 25, 2018 03:08
Download NuGet Catalog Using C# Console App
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace NuGetDownloader
{
@SteveH3032
SteveH3032 / ps-download-all-nuget-packages
Last active September 12, 2019 13:32
Nov 2018 - PowerShell script to download all NuGet packages
$indexClient = new-object system.net.webclient
$jsonIndex=$indexClient.DownloadString("https://api.nuget.org/v3/catalog0/index.json") | ConvertFrom-Json
for ($h=0; $h -lt $jsonIndex.items.Length; $h++) {
$web_client = new-object system.net.webclient
$jsonObj=$web_client.DownloadString($jsonIndex.items[$h].'@id') | ConvertFrom-Json
for ($i=0; $i -lt $jsonObj.items.Length; $i++) {
$package = $jsonObj.items[$i]."nuget:id" + "/" + $jsonObj.items[$i]."nuget:version"
$web_client.DownloadFile("https://www.nuget.org/api/v2/package/" + $package, ("C:\Nuget\" + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version" + ".nupkg"))
"Processing: " + ($h + 1) + " of " + $jsonIndex.count + " ---- " + ($i + 1) + " of " + $jsonObj.count + " - " + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version"
}