Reputation: 3176
I am fairly new to batch files, so this might seem a bit noob-ish, but here it goes :) I am trying to apply some procedures on files in a folder - loop through all files in a folder, having no extension, or having the .csv extension (this part I already figured out:
for %%i in (*.csv *.) do <command> %%i -s
But I want to skip this if I already have a %%i.txt file in that folder (i.e. - do the command only for files which do not have a corresponding .txt file int folder). This is the part I can't quite figure out...
Upvotes: 0
Views: 113
Reputation: 9545
Like this :
for %%i in (*.csv *.) do if not exist "%%~ni.txt" <command> %%i -s
Upvotes: 2
Reputation: 3176
It works with this:
for %%i in (*.csv *.) do if not exist "%%~ni.txt" <command> %%i -s
You need to use the substitution modifier "~n" to restrict the variable "i" to only the file name, and not the extension. More details here: MS Win XP Documentation
Upvotes: 0