batch file text help


  1. Posts : 1
    windows 7 32 bit o/s
       #1

    batch file text help


    I am trying to create a task using a batch file which i can then add to my windows task manager so that i can schedule it run every 7 days.

    I need the file to delet anything which is contained within the scanned documents folder. The folder is located on a network and shared by other users.

    The code that i have so far is

    set "folder=\\IVNKING\Shared Files\Scanned Documents"
    pushd "%folder%"
    for /d %%i in ('*') do rmdir "%%i" /q
    popd

    Does anybody know if this will delete only the contents of the scanned documents folder or if it will delete anything in other folders in the path.
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hi Jodie,

    Because there are single quotes placed around that asterisk of your For loop, the For loop will find nothing to loop on. The single quotes aren't meant to be there.

    Once you've fixed the For loop (by removing those single quotes), I can tell you what the batch file does: it will delete all non-hidden, empty-only folders under "\\IVNKING\Shared Files\Scanned Documents", and will not touch any files.

    Jodie959 said:
    I need the file to delete anything which is contained within the scanned documents folder.
    Below is a batch file that will do just that.
    Code:
    set "folder=\\IVNKING\Shared Files\Scanned Documents"
    pushd "%folder%" || exit /b
    del * /f /q
    for /f "delims=" %%I in ('dir /a:d /b') do rd "%%~I" /s /q
    popd
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 14:36.
Find Us