Skip to content

Instantly share code, notes, and snippets.

@bdonvr
Created June 6, 2024 07:11
Show Gist options
  • Save bdonvr/2190e985e8812cc5ca1f6089877a7738 to your computer and use it in GitHub Desktop.
Save bdonvr/2190e985e8812cc5ca1f6089877a7738 to your computer and use it in GitHub Desktop.
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:: Use WMIC to retrieve date and time in a consistent format
for /f "tokens=2 delims==," %%x in ('wmic os get localdatetime /value') do set datetime=%%x
:: Extract the date in YYYYMMDD format
set "year=!datetime:~0,4!"
set "month=!datetime:~4,2!"
set "day=!datetime:~6,2!"
:: Rename files containing 'FDD' or 'MP'
for %%i in (*FDD*.*) do ren "%%i" "8851 FDD !year!!month!!day!.xlsx"
for %%i in (*MP*.*) do ren "%%i" "8851 MP !year!!month!!day!.xlsx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment