About Delete files

I wanna create a button , it will delete some special files(for example : .bak;.tmp) in current floder (include subfolder) .

Help me to write this commands , thanks .

Delete *.(bak|tmp)

Note that, since you're specifying what should be deleted, the command will ignore the file selection and always delete all *.bak and *.tmp files in the current folder, whether they're selected or not.

If you need the command to behave slightly differently (e.g. you don't want it to prompt you before deleting the files), go to the Opus Raw Commands section of the manual to see the arguments you can give the Delete command to change what it does.

To my knowledge, the Opus raw command Delete cannot recurse through subfolders. However, the Del command from the Windows Command Prompt Console can.

The toolbar button below uses the Windows Del command to accomplish what you want—it will delete all *.bak and *.tmp files from the folder listed in the active file display, and all of its subfolders.

The Window Del command has no way of letting Opus (or you) know when it has completed, so I've added a report feature that will pop up a Notepad report of what was deleted. This file is stored in your %Temp% folder and is versioned. When you close Notepad, the report file is automatically deleted. If you wanted to save the report, save it to another location, before closing Notepad.

I needed a button like this myself. When I have time, I will make this an Opus User Command (that can accept parameters), and add some other features I need.

<?xml version="1.0"?> <button display="both" effect="gray"> <guid>{FBC50AB7-AB3E-4251-9F6E-C47825F260D0}</guid> <label>Del .bak|tmp</label> <tip>Deletes all *.bak and *.tmp files from the current folder and all subfolders.</tip> <icon1>6</icon1> <function type="batch"> <instruction>:OpusDirective</instruction> <instruction>Runmode Hide</instruction> <instruction> </instruction> <instruction>:Start</instruction> <instruction> @Echo OFF &amp; If /i NOT [%OS%]==[Windows_NT] Goto 95-98-ME</instruction> <instruction> Title Folder Tree Report</instruction> <instruction> </instruction> <instruction>:SetVars</instruction> <instruction> :: Edit the line below to include all files to delete.</instruction> <instruction> :: Surround files names with spaces inside quotes.</instruction> <instruction> </instruction> <instruction> Call Set DelFiles=*.bak *.tmp</instruction> <instruction> Call Set Filename=Delete Report--{Date|yyyy'-'MM'-'yy}-{Time|HH'.'mm'.'ss}.txt</instruction> <instruction> </instruction> <instruction>:Report</instruction> <instruction> &gt; "%TEMP%\%Filename%" Echo. Delete Report</instruction> <instruction> &gt;&gt; "%TEMP%\%Filename%" Echo. Date: {Date|yyyy'-'MM'-'yy} {Time|HH':'mm':'ss}</instruction> <instruction> &gt;&gt; "%TEMP%\%Filename%" Echo.</instruction> <instruction> </instruction> <instruction>:Delete</instruction> <instruction> &gt;&gt; "%TEMP%\%Filename%" Del /S /Q %DelFiles%</instruction> <instruction> Start /wait "Notepad" Notepad "%TEMP%\%Filename%"</instruction> <instruction> Del /Q "%TEMP%\%Filename%" &gt; Nul</instruction> <instruction> Goto :EOF</instruction> <instruction/> <instruction>:95-98-ME</instruction> <instruction> :: This script uses techniques unavailable in Windows 95/98/ME </instruction> <instruction> @Echo OFF</instruction> <instruction> Mode con: cols=35 lines=7</instruction> <instruction> Color 4E</instruction> <instruction> CLS</instruction> <instruction> Echo. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»a</instruction> <instruction> Echo. º º</instruction> <instruction> Echo. º Sorry, this button cannot º</instruction> <instruction> Echo. º support Windows 95/98/ME. º</instruction> <instruction> Echo. º º</instruction> <instruction> Echo. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼa</instruction> <instruction> Ping -n 3 127.0.0.1 &gt; Nul</instruction> <instruction> Exit</instruction> <instruction> </instruction> <instruction> :: End of :95-98-ME</instruction> </function> </button>

[ol][li]Copy the code above[/li]
[li] Right-click any Opus toolbar and select Customize from the context menu.[/li]
[li] In Customize mode, Right-click any Opus toolbar and select Paste.[/li][/ol]

Oops, I missed the sub-folder requirement.

You shouldn't have to resort to DOS commands for this as you can save a filter which matches *.(bak|tmp) and then specify it as a delete filter in the button.

That should work but I don't have time right now to work out the exact details. If you experiment, do it in a test area in case you end up deleting files/folders you didn't expect to!