While making a batch file, I thought of adding a version number to the name so new versions don't get replaced by old. What I want the new version to do is delete all the old ones, so as an example lets take a folder named apps
and in it are Test (v1).bat
, Test (v2).bat
& Test (v3).bat
. What I want Test (v3).bat
to do before anything else is delete Test (v1).bat
& Test (v2).bat
, I know what you might be thinking at this point:
Why don't you just add the lines ( del "Test (v1).bat" ) & ( del "Test (v2).bat" )?
That is not what I want, because lets say after a while I make Test (v4).bat
and want it to delete all previous versions if they exist. Obviously it wont be very optimized if I will constantly have to add & not forget to add del "Test (vā).bat"
. If I do something like this del "*.bat"
then all files with a .bat
extension will be deleted, even the currently executed one, so that doesn't help. Also I want it so if a old version is executed, then it wont delete a newer version (if Test (v2).bat
is executed don't delete Test (v3).bat
, Test (v4).bat
, etc., but delete Test (v1).bat
)