Very quick batch file question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ianpwilliams
Posts: 2
Joined: 08 Jul 2012 06:51

Very quick batch file question

#1 Post by ianpwilliams » 08 Jul 2012 06:57

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Very quick batch file question

#2 Post by foxidrive » 08 Jul 2012 08:16

This may do it (untested).

Code: Select all

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

ianpwilliams
Posts: 2
Joined: 08 Jul 2012 06:51

Re: Very quick batch file question

#3 Post by ianpwilliams » 08 Jul 2012 08:29

You are a genius sir :D

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

Post Reply