If you look in the dos help for for, e.g. help for
, you can see there are extended subsititions of the "for" variable:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only</code></pre><p>So, using <code>%%~dpnf.txt</code> will get you the input filename, but with a .txt extension.</p><p>You should also change the output redirection operator to be <code>></code> to overwrite each target text file.</p></div><div class="answer-controls post-controls"></div><div class="post-update-info-container"><div class="post-update-info post-update-info-user"><p>answered <strong>10 Feb '17, 05:39</strong></p><img src="https://secure.gravatar.com/avatar/d2a7e24ca66604c749c7c88c1da8ff78?s=32&d=identicon&r=g" class="gravatar" width="32" height="32" alt="grahamb's gravatar image" /><p><span>grahamb ♦</span><br />
19.8k●3●30●206
accept rate: 22%
Thank you! That worked very well and was much easier than I thought.
You should also change the output redirection operator to be > to overwrite each target text file.
I don’t understand that part though. What exactly is the “output redirection operator” and why would it be better to overwrite the target text file? The Text files are generated with this script, there is nothing to overwrite. Or am I missing the point?
The
>>
operator appends output to any pre-existing content. The>
operator overwrites any pre-existing content.Using the append operator could trip you up if re-running the batch file over the same captures with different tshark options.
See here for info about redirection.
If an answer has solved your issue, please accept the answer for the benefit of other users by clicking the checkmark icon next to the answer. Please read the FAQ for more information.