how to copy the latest version of previous 'file history' managed file versions to new folder

chriseldorado 20 Reputation points
2026-06-25T16:51:41.6233333+00:00

Assume each one of these files has an appropriate 'Date Modfied" stamp. Which windows command (xcopy, robocopy, other) can copy the latest over to a new folder of the same name. Would also like the resulting copy NOT have the (*UTC) encoding in the file name.

ie

orig; E:\complete orig file history\Documents\My Memoirs by Helen\

new; C:\Users\user\Documents\My Memoirs by Helen\

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_12 20_11_11 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_12 21_11_20 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_12 23_11_35 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_13 19_04_46 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_13 22_05_15 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_13 23_05_24 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2022_04_04 20_13_16 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2022_04_05 00_13_47 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2022_04_09 17_19_25 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2022_04_21 01_46_22 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2024_03_27 23_29_45 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 EARTHQUAKE (2024_06_24 23_11_05 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\1989 TICKETS (2022_04_04 19_13_10 UTC).wpd"

"E:\complete orig file history\Documents\My Memoirs by Helen\89 World Series Part #3 I sat in the Candlestick parking lot and (2024_12_12 05_08_44 UTC).wpd"

Windows for home | Windows 11 | Files, folders, and storage
0 comments No comments

Answer accepted by question author
Carl-L 22,580 Reputation points Microsoft External Staff Moderator
2026-06-26T07:55:55.42+00:00

Hello chriseldorado,

Welcome to Microsoft Q&A forum.

As I understand, you want to copy only the latest version of the file copied to the destination folder and also strip the UTC part of the name, am I correct?

The versions are encoded by the file name, not just modified date. So Xcopy and Robocopy are unable to do this. You will need to use PowerShell for this. I will assume that the destination folder already exists for this scenario.

  • Type PowerShell in the search bar and select "Run as administrator"
  • Type these commands one by one and press Enter after each.
    1. $src = "E:\complete orig file history\Documents\Memoirs by Helen"
    2. $dst = "C:\Users\user\Documents\Memoirs by Helen"
  • Paste this script and press Enter. Get-ChildItem -Path $src -File | ForEach-Object { if ($.Name -match '^(.*?) ((\d{4}\d{2}\d{2} \d{2}\d{2}_\d{2} UTC))(..*)?$') { [PSCustomObject]@{ BaseName = $matches[1] Timestamp = [datetime]::ParseExact( $matches[2], 'yyyy_MM_dd HH_mm_ss UTC', $null ) Extension = $matches[3] File = $_ } } } | Group-Object { $.BaseName + $.Extension } | ForEach-Object { $latest = $_.Group | Sort-Object Timestamp | Select-Object -Last 1 Copy-Item ` -Path $latest.File.FullName ` -Destination (Join-Path $dst ($latest.BaseName + $latest.Extension)) }

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Newest

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.