lundi 11 novembre 2019

How to replace a file at destination with a another file at source location using nested for loop in cmd

I have 3 .aar files at a source location under one folder sourcefiles for example D:\test\sourcefiles{netQ-1.aar, netQ-2.aar, netQ-3.aar}. Now i want to replace the 3 .aar files at three different locations like D:\fido\netQ-1\netQ-1.aar , D:\fido\netQ-2\netQ-2.aar and D:\fido\netQ-3\netQ-3.aar with the files at source location only if the name of files at destination location matches with the name in source location. It Means i want to replace D:\fido\netQ-1\netQ-1.aar with D:\test\sourcefiles\netQ-1.aar and similarly D:\fido\netQ-2\netQ-2.aar with D:\test\sourcefiles\netQ-2.aar and same for the third file too. For this purpose i am trying to use the nested for loop command: for /d %a in ('dir /b D:\test\sourcefiles\*.aar') do FOR /F "usebackq" %b in (DIR /s /b D:\SVN\fido.aar) do (if /i "%%~xa" equ "%%~xb" (replace the files )). In this If condition i am trying to match the file names and then do a replace operation. What is the correct command to achieve this. Any help. I know i am missing out something here please help.

  `for /d %a in ('dir /b  D:\test\sourcefiles\*.aar') do FOR /F "usebackq" %b in (`DIR /s /b  D:\SVN\fido\.aar`) do (if /i "%%~xa" equ "%%~xb" (replace the files ))`

Aucun commentaire:

Enregistrer un commentaire