When did xcopy change their flags? They added /-I as one


BobOmb

Well-known member
Member
VIP
Local time
9:41 PM
Posts
245
OS
PE
I was building out a script and I usually use /? to brush up when hand building things..

well, this particular time I made a script and shared it publicly, and didn't find out till after the fact that xcopy just added that flag

It was allowing me to rename and copy a file at the same time I would set a source and dest name using /-I to specify a file output, but when I showed the script to people it failed, and I went back and looked and /-I doesn't exist in Win 10
 

My Computer

System One

  • OS
    PE
There is weird behavior between the two types of xcopy as well commands not working on one that do on another I have to look further into it..

But until I know more I'm just using this for my scripts, the weird thing is that stuff that is working on W10 on the older version is failing on the new W11 version...
Batch:
FOR /F "usebackq delims=" %%# in (`XCOPY /? ^| findstr /C:"/-I"`) DO (
    SET newXCOPY=1
)
IF DEFINED newXCOPY (
    Use new xcopy commands here
) ELSE (
    Use old xcopy commands here
)


This works on 11 newer version that contains the new /-I flag, it copies and renames the file at the same time. It uses the new flag. Without it the user is prompted to decide what to do with the file
Batch:
XCOPY "C:\test\file1.ext" "C:\test\file2.ext" /H /C /-I /Y /Z /G /Q

EDIT: (This does work on both) This works on 10, but not 11 that has the new flag, which is why I'm confused because all I'm doing here is copying a file
Batch:
XCOPY "C:\test\file1.ext" "C:\test\" /H /C /Y /Z /G /Q
REN "C:\test\file1.ext" "file2.ext"

The changes aren't documented at Microsoft (no /-I flag mentioned anywhere)
Xcopy - Microsoft Learn

Nor are they documented at SS64 (no /-I flag mentioned anywhere)
Xcopy - Copy files and folders - Windows CMD - SS64.com

@Brink did you read anything about this anywhere as of late?
 
Last edited:

My Computer

System One

  • OS
    PE
It's not in 21H2 from September 2023, which is the last 21H2 ISO I can find. It is present in 22H2 from Sep 2022, the earliest 22H2 I can find.
 

My Computer

System One

  • OS
    Windows 11 Pro 25H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Core i7-1260P
    Motherboard
    NUC12WSBi7
    Memory
    64 GB Micron PC4-25600
    Graphics Card(s)
    Intel Iris Xe Graphics
    Sound Card
    on-board Realtek HD Audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840 x 2160
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Crucial MX500 2 TB
    Antivirus
    Microsoft Defender
I think the behavior issue I'm experiencing is unique to what I'm doing and some other part of what I'm working on was causing me to believe xcopy was failing. The file was present it was only hidden, i needed to ATTRIB it (using old 10 commands on 11)

Still interesting the flag has been present this long and is still undocumented

In short it would have still caused me some issues but not as severe as failing commands, so scripts that were working prior should still remain usable (from what I can tell). It's also good to know if I write something on a newer machine with that flag that it will fail on older systems.
 

My Computer

System One

  • OS
    PE
Yeah probably pretty annoying if you're using xcopy. To be honest, I forget xcopy even exists. It's robocopy for me.
 

My Computer

System One

  • OS
    Windows 11 Pro 25H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Core i7-1260P
    Motherboard
    NUC12WSBi7
    Memory
    64 GB Micron PC4-25600
    Graphics Card(s)
    Intel Iris Xe Graphics
    Sound Card
    on-board Realtek HD Audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840 x 2160
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Crucial MX500 2 TB
    Antivirus
    Microsoft Defender
Back
Top Bottom