Skip to main content

Posts

Use Python to add a file's modification time to the front of the file name

# Add a file's modified time to the front of the name of the file in the format # YYYY-MM-DD-<original-filenam>. # # Works for files in the current directory. from os import listdir from os.path import isfile, join import os import time mypath = "." onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] for file in onlyfiles:   newname = time.strftime('%Y-%m-%d-', time.gmtime(os.path.getmtime(file))) + file   print("Renaming file: " + file + " to: " newname)   os.rename(file, time.strftime('%Y-%m-%d-', time.gmtime(os.path.getmtime(file))) + file)
Recent posts

Use Robocopy To Backup Files

robocopy C:\Users\username\Documents\ E:\Backup\ /MIR /XJD > Backup.log echo "DONE" >> Backup.log Dry Run: robocopy C:\Users\username\Documents\ E:\Backup\ /MIR /XJD /L > Backup.log rem Copy files to backup volume rem /MIR - Mirror files (delete files on destination that aren't on the source) rem /XJD - Exclude junction points for directories (may cause infinite loops) rem /sl - Don't follow symbolic links and instead create a copy of the link. rem /FFT - 2 second difference when comparing timestamps rem /R:3 - Only retry 3 times (default is 1 million) rem /W:10 - Wait time between retries (default is 30) rem /Z - Copies files in restart mode (NOTE: This WILL slow down copying) rem /B - Backup mode - allows copy of open files (must run as Admin) rem NOTE: /Z and /B can be combined as /ZB rem /NP - Don't output progress of copy operation rem /log:backup.log - Logs to backup.log, overwriting old log file (use /log+: to append) rem /

How to get information about a running process in Windows

wmic allows you to get a lot of information about processes running on a Windows computer. Here are some useful examples To get a list of all running processes: C:\> wmic process list brief To get information about a process with a specific PID: C:\> wmic process where processid=1120 Or to just get the command line: C:\> wmic process where processid=1120 get commandline

IIS and Windows 2012 Notes

Shut down IIS: net stop was /y Start IIS: net start w3svc Show active http bindings: netsh http show servicestate Config file schemas can be found here: C:\Windows\system32\inetsrv\config\schema\IIS_schema.xml Internet Information Services: What’s New in Window Server 2012 R2

Windows 8 Keyboard Shortcuts

http://www.pcworld.com/article/2012885/20-must-know-windows-8-tips-and-tricks.html The Windows key + I opens the settings menu, giving you quick access to the Control Panel, Personalization, and your Power button, among other features. The Windows key + Pause opens the system properties page to show you a quick rundown of your specs.

A simple IIS HTTP module to log request headers and post data

This is a simple http module that hijacks the incoming request and logs it to a file. Using this module prevents the application from getting the post data because the input stream can only be read once. With .NET 4.0 the module could be much smaller, and could allow the application to read the data. To compile this, create a new "Class Library" application called PostDataLogger. Most of this class is pieced together from stolen code (stack overflow, etc.) using System; using System.IO; using System.Web; /// /// Dump PostDataLogger.DLL in your bin, and put this in your web.config inside of /// /// /// /// public class SimpleLogger : IHttpModule { private HttpApplication _ctx; public void Init(HttpApplication context) { _ctx = context; context.BeginRequest += new EventHandler(Context_BeginRequest); } void Context_BeginRequest(object sender, EventArgs e) { string GUID = Guid.NewGuid().ToString(); string filename = @"d:\temp\adeber