Skip to content

Instantly share code, notes, and snippets.

@csereno
Last active March 6, 2018 19:57
Show Gist options
  • Save csereno/c9fb7a3b444b9c9f0db408d29a399b21 to your computer and use it in GitHub Desktop.
Save csereno/c9fb7a3b444b9c9f0db408d29a399b21 to your computer and use it in GitHub Desktop.
PowerShell script to rename file(s) to WireShark fileset format
# Created by csereno
# 1. Copy the file into a folder on your PC
# 2. Add the capture files to the folder
# 3. Run the script
#
$capname = Read-Host -Prompt "What is the new file name?"
$i=1
dir *.*cap* | %{Rename-Item $_ -NewName ($capname + '_{0:D5}{1}' -f $i++,($_.Extension -replace '[^a-zA-Z.]',''))}
dir *.*cap* | Rename-Item -NewName {$_.BaseName+'_'+$_.LastWriteTime.ToString('yyyyMMddHHmmss')+($_.Extension -replace '[^a-zA-Z.]','')}
@csereno
Copy link
Author

csereno commented Mar 6, 2018

added code to strip numbers from the end of the file in the extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment