[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2009-04-02
3
Medium Priority
?
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 1000 total points
ID: 24053017
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
ID: 24053041
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
ID: 31565926
Perfection, Thank you
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

656 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