Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Delete all files apart from all video types and images  (Read 7971 times)

0 Members and 1 Guest are viewing this topic.

blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #15 on: November 23, 2014, 01:52:20 PM »
i ment to say there on on C:\ the external HDD is H and no foldes just the files


foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Delete all files apart from all video types and images
« Reply #16 on: November 24, 2014, 01:15:29 AM »
These two commands will use drive h: and the file.txt will be saved on your desktop.
Follow the points I outlined in the earlier post.

Code: [Select]
dir h:\*.* /b /a-d |findstr /v /i /L ".mpg .mkv .mpg .mpeg .jpg .png .bmp .gif" >"%userprofile%\desktop\file.txt"

Code: [Select]
for /f "usebackq delims=" %a in ("%userprofile%\desktop\file.txt") do del "%a"

blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #17 on: November 24, 2014, 05:40:55 AM »
Ive ran the file txt ill keep you posted when i come back later
« Last Edit: November 24, 2014, 06:20:38 AM by blackrainbow »


blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #18 on: November 24, 2014, 10:00:28 AM »
Ive ran the Delete side of the script and it saying files not found :/

[attachment deleted by admin to conserve space]
« Last Edit: November 24, 2014, 10:31:48 AM by blackrainbow »


Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Delete all files apart from all video types and images
« Reply #19 on: November 24, 2014, 10:42:02 AM »
Ive ran the Delete side of the script and it saying files not found :/
You know it is possible to copy and paste text from the CMD window.

blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #20 on: November 24, 2014, 10:46:21 AM »
Squashman yeahh i know that,


Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Delete all files apart from all video types and images
« Reply #21 on: November 24, 2014, 10:49:47 AM »
Since you are not running both commands from the H:\ drive on the command prompt then you need to hard code both commands to use the H: drive.

Code: [Select]
for /f "usebackq delims=" %a in ("%userprofile%\desktop\file.txt") do del "H:\%a"

blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #22 on: November 24, 2014, 10:55:44 AM »
how would i do that  ive tried to use the dir H:\ bfor the code


Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Delete all files apart from all video types and images
« Reply #23 on: November 24, 2014, 11:02:24 AM »
how would i do that  ive tried to use the dir H:\ bfor the code
Well you don't need to if you use the small code variation I made to Foxidrive's code.

Code: [Select]
C:\Users\Squashman>H:

H:\>

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Delete all files apart from all video types and images
« Reply #24 on: November 25, 2014, 06:33:29 AM »
I'm sorry, I initially used a recursive search and removed the /s while editing it because you hadn't mentioned if there were subdirectories, but Squashman's modification will work if all the files are in H:\ and the following modification should work too if there are no subdirectories - I put the /s back in.

Code: [Select]
dir h:\*.* /s /b /a-d |findstr /v /i /L ".mpg .mkv .mpg .mpeg .jpg .png .bmp .gif" >"%userprofile%\desktop\file.txt"

Code: [Select]
for /f "usebackq delims=" %a in ("%userprofile%\desktop\file.txt") do del "%a"


blackrainbow

    Topic Starter


    Hopeful

  • For the Emperor!
  • Thanked: 9
    • Yes
    • Yes
    • Freaks geeks and autographs shop
  • Experience: Familiar
  • OS: Windows 7
Re: Delete all files apart from all video types and images
« Reply #25 on: November 26, 2014, 06:24:55 AM »
ive done it following squashmans adcive thanks guys :D:D