Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am a Batch-newbie...

This "tool" is to automate the slimming down of Windows (XP) by disabling certain system driver, DLL and EXE files. Instead of outright deletion, I wish to rename-in-place, thus "removing" them from the OS, but not losing sight of where they belong (should any need to be "restored"). Renaming is accomplished by appending a new suffix to the existing filename (eg: "wdmaud.drv.group_1") The renaming suffix should be another input variable.

The target-list is approx. 1100 files long (divided into various groups/phases), so manual renaming is out of the question. Each group will be processed in a separate run of the batch file, varying the target-list input file for each execution.

Target-list is plain text file, one filename per line (no other data in the files). Number of entries per group varies. Target list will look like this:

    -- example start --
    -- example end --

Filenames may be in UPPER, lower, or MiXeD case. The files may be present in more than one folder in the C:\Windows hierarchy - or may not be present at all. If a file is not found anywhere in the system, it's name should be written to a text file, one-entry-per-line.

The specific folders of interest are:


...but may change as development proceeds.

Based on a reply at stackoverflow.com, I've got started thus:

    @echo off

    set suffix=GROUP_1
    set targetlist=GROUP_1.txt
    set dirlist=folders.txt

    for /f "tokens=*" %%f in (%targetlist%) do (
      for /f "tokens=*" %%d in (%dirlist%) do (
        if exist "%%d\%%f" ren "%%d\%%f.%%suffix"
           echo %%f found in %%d >> foundlist.txt


    :: -----------------------------------------------------------------::
    :: Batch Process to Rename-In-Place System Files from an Input List ::
    :: -----------------------------------------------------------------::

    @echo off
    :: >> clear files from previous run <<
    if exist RENAMED_files.txt  DEL RENAMED_files.txt
    if exist NOTFound_files.txt DEL NOTFound_files.txt

    ::  >> file rename-suffix reflects step name <<
    set suffix=Steppe_01

    ::  >> target file list to rename <<
    set targetlist=Steppe_01_files.txt

    ::  >> list of folders to search  <<
    set dirlist=folders.txt

    ::  >> PROCESS <<

    for /f "tokens=*" %%f in (%targetlist%) do (
      echo. >> NOTFound_files.txt
      for /f "tokens=*" %%d in (%dirlist%) do (
        if NOT exist "%%d\%%f"          echo %%f  not in %%d >> NOTFound_files.txt
        if exist     "%%d\%%f"          REN "%%d\%%f" "%%f.%suffix%"
        if exist     "%%d\%%f.%suffix%" echo renamed  %%f  in %%d >> RENAMED_files.txt

    ::  >> end of process <<
share|improve this question
Windows File Protection is about to hit you over the head with a large hammer. Don't say later that you weren't warned. –  JdeBP Oct 7 '11 at 9:21
What is the question? –  Paul Oct 12 '11 at 3:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.