Windows 10: Batch script question

  1.    19 Aug 2016 #1

    Batch script question


    Hello,

    I want make a batch script to delete a spefic folder on the C disk, but how can I get only that spefic folder? I got this:
    Code:
    FOR /D %%p IN ("C:\USERS\%USERNAME%\Downloads\*.*") DO rmdir "%%p" /s /q
    cd C:\USERS\%USERNAME%\Downloads\
    del *.* /q /s
    timeout /t 5 >nul 2>&1 /nobreak
    cls
    It works currently for the Downloads folder, but how can I change that?
      My ComputerSystem Spec

  2.    21 Aug 2016 #2

    UP.
      My ComputerSystem Spec


  3. Posts : 2,284
    Windows 10.3 Home 1703 x64 (Home per choice)
       21 Aug 2016 #3

    That script looks so complicated, I prefer simple ones like:

    Code:
    rmdir "%USERPROFILE%\Downloads" /s /q
    mkdir %USERPROFILE%\Downloads
      My ComputerSystem Spec

  4.    21 Aug 2016 #4

    And how would that work for the C:\ folder?
      My ComputerSystem Spec


  5. Posts : 2,284
    Windows 10.3 Home 1703 x64 (Home per choice)
       21 Aug 2016 #5

    %USERPROFILE% will choose the current user profile wherever it is located.

    If you want to specify a system disk, you can use %SystemDrive%

    A random folder would be:

    rd ""C:\AMD"" /s /q

    rd ""%SystemDrive%\AMD"" /s /q
      My ComputerSystem Spec

  6.    21 Aug 2016 #6

    Code:
    FOR /D %%p IN (%SystemDrive%\Windows.old) DO rmdir "%%p" /s /q
    cd %SystemDrive%\Windows.old
    del *.* /q /s
    timeout /t 5 >nul 2>&1 /nobreak
    cls
    That?
      My ComputerSystem Spec


 

Related Threads
Batch File Help in Software and Apps
I've never dabbled much in batch files, as I've usually been able to find pre-made ones to do what I wanted. We have an application that handles user data backups. It has three services, and at times, one or two of the three don't start...
Solved Batch Append Mp3 Tags in Software and Apps
Does anyone know of any software, or hack, or any other way that will allow me to batch append mp3 metadata tags to about 1000 mp3 files. There are 1000 songs, different titles, different artists, different genres. Lets say all of these are pop...
Can't download batch file in General Support
Can't download batch file "10services_default.bat" to solve windows 10 start menu problem.
Solved Writhing Batch File in General Support
Here is my batch file but it will not delete the file? Must be missing something :( del "C:\Users\Larry\AppData\Local\TractorParts\tractor\ConfigSetting" Trying to delete the ConfigSetting File
Sub-script and Super-script in General Support
Is it possible to use sub-script and super-script when typing emails with Windows 10? I was able to do this when using Windows 7 and typing documents but not for emails. I was expecting that with the major up-grade to from 7 to 10 it would now be...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 08:54.
Find Us