Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FileTerminator Batch/CMD Script
#1
Here's a demo of a new script i've been working on. This one is different so be sure you view the video to get an idea of how it works.

[yt]http://www.youtube.com/watch?v=nsdfK_vR9LQ[/yt]

What this does is it takes the file you dropped onto the batch, and reads the filepaths to the files specified on each line that determines what it deletes. You can use a * wildcard as shown in the video to delete files.

It creates a Termination_Log file which you can open in notepad that contains the file deletion script that you used in case you need it for reference.

If you want to delete all files of a file extension:
Code:
*.fileextension

Or if you want to delete all files in all file extensions with a specific filename:
Code:
filename.*

Make sure you use a full filepath to the files you want to delete. Don't use anything but the filepath, no quotes, no commas, etc...
Example:
Code:
C:\MyUsername\Something\Something\SomeFile.FileExtension

If you use a wildcard, it will ONLY delete the files in the same directory as the one you specify to look for the files using the wildcard. It won't look in subdirectories, just to make this batch script a little safer. I've also put in a confirmation message at the beginning in case you accidentally drop a file on the batch script.

Here's the batch script: I save it with the .cmd extension, but you can use .bat for this script as well.
Code:
@echo off
Title Ace's FileTerminator
mode con: cols=55 lines=10
set errorh="%1"
set val=0

echo.This script will delete all of the files specified
echo.on each line of the file you dragged over this
echo.batch file. If only a filename was specified
echo.the script will look in the same directory of the
echo.batch file for that filename to delete.
echo.
echo Are you sure you want to delete the files^?
echo.
echo.   [Y] - Continue
echo.   [Q] - Quit and Exit
echo.

choice /c:YQ>nul
if errorlevel 2 exit

mode con: cols=75 lines=20
echo Ace's File Terminator>Termination_Log
echo %Date% - [%Time%]>>Termination_Log
echo.>>Termination_Log
echo Current Directory: %CD%>>Termination_Log
echo.>>Termination_Log

echo Deleting File^(s^):
echo.

for /f "tokens=*" %%i in ('type "%errorh%"') do (
    del /f /q "%%i">nul
    echo.  ^> Deleting File^(s^): %%i>>Termination_Log
    echo.  ^> %%i
    set /a val+=1
)

echo. >>Termination_Log
echo -- Created by Ace ^(2011^) -- >>Termination_Log

echo.
echo %val% file^(s^) have been deleted
echo Press any key to finish...
pause>nul
Reply
#2
That's a great script you made ! I will test it in a few hours .
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass Generator Batch script AceInfinity 0 902 09-30-2012, 10:17 PM
Last Post: AceInfinity
  Batch tutorial goes here? fanta 3 1,514 05-22-2012, 09:25 PM
Last Post: AceInfinity
  [Batch] Trick - View Environment Variables AceInfinity 0 974 05-05-2012, 07:01 PM
Last Post: AceInfinity
  [Batch] Quick Drive Information Script (Created by AceInfinity) AceInfinity 17 7,243 02-09-2012, 08:10 AM
Last Post: AceInfinity
  [Batch Game] Rock, Paper, Scissor by Hack0pz hackopz 3 2,571 01-22-2012, 05:17 PM
Last Post: AceInfinity

Forum Jump:


Users browsing this thread: 1 Guest(s)