Skip to content

Instantly share code, notes, and snippets.

@bigjosh
Created March 27, 2024 02:22
Show Gist options
  • Save bigjosh/398d8dfe9e2cc91c13aa9e76da1799d8 to your computer and use it in GitHub Desktop.
Save bigjosh/398d8dfe9e2cc91c13aa9e76da1799d8 to your computer and use it in GitHub Desktop.
REM Move all of the files from a recently inserted USB drive to a directory on a local hard drive.
REM Edit these to set the correct paths for your USB drive and the location where you want the files to end up.
set "SRC=J:\RECORD"
set "DST=D:\Users\josh\Documents\OrsonEar"
REM This should be set up inside Task Schedualer to run on the follwoing event:
REM Log : Microsoft-Windows-DeviceSetupManager/Admin
REM Source : DeviceSetupManager
REM Event ID : 112
REM See https://std.rocks/windows_event_on_usb.htm
:: Get the current date in YYYY-MM-DD format
for /f "tokens=2 delims==" %%i in ('wmic os get localdatetime /value') do set datetime=%%i
set "YEAR=%datetime:~0,4%"
set "MONTH=%datetime:~4,2%"
set "DAY=%datetime:~6,2%"
set "CURRENT_DATE=%YEAR%-%MONTH%-%DAY%"
:: Define the destination directory with the current date
set "DEST_DIR=%DST%\%CURRENT_DATE%"
:: Check if the destination directory exists, if not create it
if not exist "%DEST_DIR%\" mkdir "%DEST_DIR%"
:: Move all files from the source directory to the destination directory
move "%SRC%\*" "%DEST_DIR%\"
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment