removing extra files in dos

Hi,

I have same file by name

i want to keep only access file and want to delete rest. This is specific to DOS only.
Any idea of doing this. I tried so many options but none worked for me.

Thanks
Namish

You mean , these files are not in unix ?..

No these are not in unix. this is on windows box.

del access.???

-Enjoy
fh : )_~

Hi Festus,

i have already tried this option and it does not work. it will delete all the files including access.

it works as if dot is not there.
Should there be some regexs to match numbers in batch scripts?

I did not get what you want to say here.

Thanks
NT

Hi Namith ,

The only way i found is

del access.0*

What dos???
Must be one of the newer M$lop... xp|>

That should not happen ... That is the correct method.
The .??? signifies that there must be 3 characters following a dot!

If the .0?? or .0* don't work for ya, move your access file to another dir then del *.*... then it can't delete it... :slight_smile:

-Enjoy
fh : )_~

Create a batch (.bat) file not called access.bat (!) containing:

for %%f in (access.???) do @echo del %%f | find "." >> temp.bat
call temp.bat
del temp.bat

Explanation: Generates a list of all files access.??? (which includes "access"), output in format "del filename" but ignore line not containing "." . Then execute the output batch file "temp.bat".

try this

for /f "usebackq" %%i in (`dir /b access.*`) do (
	if not %%i==access del /f /q %%i
)

Combined with b33713 ideas:

@echo off
for %%f in (access.???) do (if not %%f==access del %%f)