Notes from Daily Encounters with Technology RSS 2.0
 
# Tuesday, July 24, 2007

Figuring this out took me much longer than it should. The following line in a batch file will execute a command for each file in a directory:

for %%I in (C:\*.*) do echo %%~nxI

I had to overcome two obstacles to make this work:

  • When including the command in a batch file the % characters must be duplicated in comparison to the syntax for executing the command directly from the command line.
  • The ~nx prefix to the variable name causes only the filename with extension to be used instead of the complete path.
Tuesday, July 24, 2007 4:19:03 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Development | Scripting
Page 1 of 1 in the DevelopmentScripting category
Sponsored Ads

About Me

Damir Arh

Microsoft Certified Professional

View Damir Arh's profile on LinkedIn

Profile for ExAmigan

ExAmigan

Twitter
RT @MladenPrajdic: RT @danmartell: Top Five Regrets of the Dying http://bit.ly/b8Qywr #MustRead #Friends 11 hours ago
On my way to Celje today I've seen parhelion (sundog) for the first time http://imgur.com/NssST http://digs.by/dm1TUQ 4 days ago
How to setup WinMerge as compare tool in Total Commander: http://digs.by/bquumI 5 days ago
Damir's Corner: EventLogTraceListener Can Cause an Application to Crash http://goo.gl/fb/bxEGC 6 days ago
How to debug .NET Framework Source in VS2010 http://digs.by/dr382h 6 days ago
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

All Content © 2010, Damir Arh, M. Sc. Send mail to the author(s) - Privacy Policy - Sign In
Based on DasBlog theme 'Business' created by Christoph De Baene (delarou)