Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-15
2
Medium Priority
?
433 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:rebelscum0000
2 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 36550477
After some minor corrections, the script runs as expected:
@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 /E
   rd "%%~D" 2>nul
) 
popd

Open in new window

The corrections are:
* removed backslash from robocopy source folder name (you took the wrong code, it's already corrected in the other question)
* added /E to robocopy options
* added popd at the end of file
That's all what has been needed.
0
 

Author Closing Comment

by:rebelscum0000
ID: 36564913
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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question