Create unique file name Windows batch

前端 未结 10 1448
闹比i
闹比i 2020-12-16 15:57

I have seen many posts about creating a unique filename from the naive %TIME% to the plausible (but insufficient) %RANDOM%. Using wmic os get localdatetime is m

10条回答
  •  天涯浪人
    2020-12-16 16:11

    I like Aacini's JScript hybrid solution. As long as we're borrowing from other runtime environments, how about using .NET's System.GUID with PowerShell?

    @echo off
    setlocal
    
    for /f "delims=" %%I in ('powershell -command "[string][guid]::NewGuid()"') do (
        set "unique_id=%%I"
    )
    
    echo %unique_id%
    

提交回复
热议问题