Solved

Need batch file to delete all files but jpg and flv extensions

Posted on 2009-04-02
3
324 Views
Last Modified: 2013-11-10
Hello all, need a batch file to loop through a folder and delete all file types but .flv and .jpg

Thank you
0
Comment
Question by:details212
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
Comment Utility
This should work - change the folder name and remove the 'echo' from the last command line if it displays as you anticipate
setlocal enabledelayedexpansion

cd /d f:\test

for /f %%a in ('dir /a-d /b') do (

  set file=%%~fa

  set filename=%%a

  set fileext=%%~xa

  If not [!fileext!==[.flv (

    If not [!fileext!==[.jpg (

      echo erase !filename!

    )

  )

)

Open in new window

0
 
LVL 6

Expert Comment

by:IKZ
Comment Utility
When you make your batch file- use the *.flv and *.jpg as your wild cards. Or set it up to move all *.flv and *.jpg files to a temporary directory- then delete all remaing files in the folder, then move all files back from the temp directory.  Let me know if you need more guidance.
0
 

Author Closing Comment

by:details212
Comment Utility
Perfection, Thank you
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now