Page 1 of 1

Very quick batch file question

Posted: 08 Jul 2012 06:57
by ianpwilliams
I have a very simple batch file for extracting certain lines from a particular file, and then outputting those lines to a new file:

findstr "SUMMARY" 20120708.ics > test.txt

What I would really like to be able to do is drag any ics file onto the batch file icon in a Windows XP window, and have the batch file search for the string in that file, rather than searching the 20120708.ics file. I would also really like the output file to be the same name as the file that I dragged onto the batch file icon, but with the extension "txt" instead of "ics". What would I need to change in this command for that to work?

Re: Very quick batch file question

Posted: 08 Jul 2012 08:16
by foxidrive
This may do it (untested).

Code: Select all

@echo off
findstr "SUMMARY" "%~f1" > "%~dpn1.txt"

Re: Very quick batch file question

Posted: 08 Jul 2012 08:29
by ianpwilliams
You are a genius sir :D

Makes me want to get back into computer programming again...