Remove directories with wildcards in .bat file RRS feed

  • Question

  • I know there are several similar topics on this, but none that exactly fit my situation. I need to delete a directory and all subfolders here: c:\Users\%%\AppData\Local\virt-viewer

    The %% being the wildcard user.

    I have tried FOR /D %X IN ("c:\Users\*\AppData\Local\virt-viewer") DO RD /S /Q "%X" in a command prompt (doubling the % in a batch), but nothing has worked yet.

    Friday, May 2, 2014 2:04 PM


All replies

  • i modified it a bit, and got closer. but still not completed.

    for /D %m in (C:\Users\*) Do RMDIR /S /Q "C:\Users\%m\AppData\Local\virt-viewer"

    The filename, directory name, or volume label syntax is incorrect.

    I get this error, despite the directory being correct

    Friday, May 2, 2014 2:32 PM
  • Solved my own problem.

    For /D %%m in (C:\Users\*) Do RMDIR /S /Q "%%m\AppData\Local\virt-viewer"


    Friday, May 2, 2014 2:40 PM
  • Troubleshooting tip for shell commands: Put the echo command before your rmdir command to see what it's doing.

    -- Bill Stewart [Bill_Stewart]

    Friday, May 2, 2014 2:41 PM