;Find and print all the lines matching "/images/YYYY" which do not have the form '/images/year/' for ( %f in *.shtml ) do sed -n "/\/images\/[0-9]4[^\/]/p" %%f