@echo off
setlocal enableextensions disabledelayedexpansion
pushd "c:\target\folder" && (
for /f "tokens=1,* delims=." %%a in ('
dir /a-d /b "TOP_QUERIES-www.*.csv"
') do echo del /q "TOP_QUERIES-%%b" 2>nul
popd
)
This changes the current active directory to the one containing the files and for each www prefixed one, tries to delete the corresponding paired file. If it does not exist, the error is discarded. At the end, the current active directory is restored
To detemine the name of the file to delete, a for /f is used to tokenize the file name using dots as delimiters. We request two tokens (tokens=1,*), the first token precedes the first delimiter and is stored in the %%a replaceabe parameter while the second token requested is the rest of the file name and is stored in the %%b (the next one alphabetically) replaceable parameter.
Delete operations are only echoed to console. If the output is correct, remove the echo command before the del
www.?or you want all files deleted?TOP_QUERIES-filename.com.csvandTOP_QUERIES-www.filename.com.csv. so those double files i want to get rid of where il keep the ones havingwwwin it