Announcement

Collapse
No announcement yet.

Need a little help with batch file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need a little help with batch file

    I am trying to write a batch file that looks in all the directories withing a folder and deletes all the .xls files in all the folders.
    So I have folder structure
    Main Directory
    -Dir 1
    -Dir 2
    -Dir 3

    Inside each of those Dir's there are .xls files. I want to delete all of them, could someone help me write a batch file to do this?

    Thanks!!

  • #2
    Originally posted by BlueGrimRX8
    I am trying to write a batch file that looks in all the directories withing a folder and deletes all the .xls files in all the folders.
    So I have folder structure
    Main Directory
    -Dir 1
    -Dir 2
    -Dir 3

    Inside each of those Dir's there are .xls files. I want to delete all of them, could someone help me write a batch file to do this?

    Thanks!!
    cd \"Main Directory" (quotes not needed if directory name has no spaces)

    cd "dir 1"
    del *.xls /q
    cd..
    cd "dir 2"
    del *.xls /q
    cd..
    cd "dir 3"
    del *.xls /q
    cd..
    exit

    Hope that helps

    Comment


    • #3
      cd\yourdirectory <------ This is the root of your directory structure
      del *.xls /s

      Put that in your batch file and it should work.

      Thanks,

      Paul.
      Ford Transit 135 T350
      1Ghz Epia M10000 ITX
      OPUS 150w
      512MB DDR
      40GB HD
      7" Lilliput Touch Screen (Powered from Opus)

      0% Completed - Used to have this PC in my Ford Focus RS for fun but now I have it in my van for work! It's awsome!

      Comment


      • #4
        Thanks paul thats exactly what I was looking for. Eleventh, that would have worked to but I have over 2000 subdirectories.

        Thanks guys knew somebody could help!!

        Comment


        • #5
          Originally posted by BlueGrimRX8
          Thanks paul thats exactly what I was looking for. Eleventh, that would have worked to but I have over 2000 subdirectories.

          Thanks guys knew somebody could help!!

          Gotcha - I didn't know if there were some directories in Yourdirectory that you didn't want to delete the .xls's in, that's why I didn't reccommend /s. Happy coding.

          Incidentally, if you want to turn your bacth file in to an exe check this out: http://www.bdargo.com/index.htm

          Comment

          Working...
          X