Windows 10: Deleting files using a batch file

Discus and support Deleting files using a batch file in Windows 10 Software and Apps to solve the problem; I created a batch file using AI to delete files older than 3 months from a specific folder but the code I received does not work:. Files are dated in... Discussion in 'Windows 10 Software and Apps' started by dmkkg, Apr 8, 2024.

  1. dmkkg Win User

    Deleting files using a batch file


    I created a batch file using AI to delete files older than 3 months from a specific folder but the code I received does not work:. Files are dated in DD/MM/YYYY format in the folder.@echo offset "folder=C:\Users\CC\Documents\0Temp"set "cutoffdate="for /f "tokens=1-3 delims=/" %%a in 'date /t' do set /a "mm=1%%b%%100" & set /a "yy=%%c"rem Calculate the month and year for the cutoff dateif %mm% gtr 3 set /a "mm=mm-3" else set /a "mm=mm+9" set /a "yy=yy-1"rem Ensure mm has leading zero if less than 10if %mm% lss 10 set "mm=0%mm%"rem

    :)
     
    dmkkg, Apr 8, 2024
    #1

  2. Batch file

    thank you for your reply. how to merge the codes so that the batch file does this

    the batch file displays the options below

    1. open the *.spl file in notepad
    2. delete the *.shd and *.spl files
    3.exit

    commands execute as options are selected
     
    Sandeep Bhugoo, Apr 9, 2024
    #2
  3. oily_17 Win User
    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Apr 9, 2024
    #3
  4. Deleting files using a batch file

    Batch file

    in fact when i reset a user password it is supposed to print the generated password to a printer but i don't want to print it. i want the batch file to open the .spl file generated in notepad, i note the password then on closing the notepad, the files .shd and .spl are deleted permanently from the folder
     
    Sandeep Bhugoo, Apr 9, 2024
    #4
Thema:

Deleting files using a batch file

Loading...
  1. Deleting files using a batch file - Similar Threads - Deleting files using

  2. Deleting files using a batch file

    in Windows 10 Gaming
    Deleting files using a batch file: I created a batch file using AI to delete files older than 3 months from a specific folder but the code I received does not work:. Files are dated in DD/MM/YYYY format in the folder.@echo offset "folder=C:\Users\CC\Documents\0Temp"set "cutoffdate="for /f "tokens=1-3 delims=/"...
  3. Batch File

    in Windows 10 Software and Apps
    Batch File: Hi, I am trying to create a batch file to determine whether a user account is signed on.I don't have enough experience to get it to @Echo it worked. Any advice please.Batch file:REM Query whether user SBackup is active@echo onsetlocal enabledelayedexpansionset...
  4. Batch Files

    in Windows 10 Gaming
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  5. Batch Files

    in Windows 10 Software and Apps
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  6. Batch Files

    in Windows 10 Network and Sharing
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  7. Batch files for use in BSOD debugging

    in Windows 10 BSOD Crashes and Debugging
    Batch files for use in BSOD debugging: [img] Warning This thread is for use by the BSOD team ONLY, to store batch files that can be used to collect additional data, fix settings or anything else that is useful in debugging BSOD problems in Windows 10. [img] Information The way I see it working is the first post...
  8. Delete similar files by batch file?

    in Windows 10 Graphic Cards
    Delete similar files by batch file?: Hello everybody! I'm writing a batch file that I want to use to delete different folders, whose folder name starts with the same name (e.g. Test) but ends differently (i.e. test number, test digit, etc.). Is there any solution for this? Or do I have to list every single...
  9. Batch File

    in Windows 10 Support
    Batch File: I need a batch file to create a folder with sub folders. The sub folders will be named the current date, they will go in a folder on c drive. For example we can call the folder test and it would be in documents on c drive. Every time we run the batch file it would create a...
  10. Batch Rename Deletes Files

    in Windows 10 Performance & Maintenance
    Batch Rename Deletes Files: Hey all, I just upgraded to Windows 10 last night, and I've been playing around with the new File Explorer. One thing I tried was the batch rename function (by which I mean just selecting multiple files and clicking "rename"). I quickly realized that it behaves differently...