Link to home
Start Free TrialLog in
Avatar of Claudio Herrera
Claudio HerreraFlag for Mexico

asked on

Expert Qlemo or others Expert How do I move C:\Windows\$NtUninstall to another folder using a batch file?

I have this batch file without the /MOVE option, I would like to include it in order to move the target folder, and their contain files

In order words
I need a code WHICH
MOVE WITH the criteria to "all folders C:\Windows\$*, but not $hf_mig$" AND their contents of each folders TO C:\Backup\NtUninstall\
IF all folders FROM C:\Windows\$*, but not $hf_mig$" AND their contents (are) MOVE TO C:\Backup\NtUninstall\ I will NOT have to have at C:\Windows\ any folder that start WITH "$" except the folder $hf_mig$ and the folder's contains of the MOVEd TO C:\Backup\NtUninstall\

@ECHO OFF
pushd %SystemRoot%
for /F "tokens=*" %%D in ('dir $* /b /a:d ^| find /v "$hf_mig$" ') do (
   md C:\Backup\NTUninstall\%%~nxD 2>nul
   robocopy "%%~D\" "C:\Backup\NtUninstall\%%~nxD" /MOVE
   rd "%%~D" 2>nul
) 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Claudio Herrera

ASKER

Excellent!!, That is what I want, the batch file MOVES all the folders and their contents FROM C:\Windows\$*, but not $hf_mig$ to another location in this case C:\Backup\NTUninstall\

Thank you very much