I'd need a script for deleting .exe and creating a dummy

Hello,

I'd need a script to do the following: search in all subfolder of a given root folder for *.exe files, then delete the .exe file from the folder where it resides and do also create a new file: "xyz.exe.txt" while xyz is the name of the deleted .exe. This dummy file *.exe.txt should be there as a reminder.
Just renaming the .exe to .txt wouldn't do it as e.g. some .exe file are quite big in size , but what I just want is a simple *.exe.txt file with 1KB

Can you give me a hint, example etc how to do s.th. like this?

Kind Regards

This isn´t maybe the most elegant code, but could be a good starting point for you. It deletes exe files
in the current folder & the subfolders, then puts some file into the directory. You might have to tweak
it a bit for your needs. Please run a few tests before actually using it.

Set FLATVIEW=On,MixedNoFolders SHOWFILTERFILENAME=*.exe select ALL Clipboard COPYNAMES delete ALL CLIPBOARD PASTE AS exes.txt Set SHOWFILTERFILENAME=*.*

Hmm, the summary of deleted exes is all in the text file, but doesn´t replace the files the way you asked.
I can´t figure out how to achieve this at the moment, because the code is based on the flat view, making it
a bit difficult to process the files one by one, placing the files in their respective folders.

Hi abr,
thanks so far for your reply. I didn't do any coding within DOPUS, yet. So, I'll try it out with some test folders.

launchee if I understand what you want to do, then I think it would take an external script to do exactly what you want. So here is the way I would do this.

First using Notepad create a new empty text file and paste the following into it:

@echo off if not "%OS%"=="Windows_NT" exit if {%1}=={} exit pushd %1 for /r %%a in (*.exe) do ( type nul>"%%~dpa%%~na%%~xa.txt" del "%%~a" ) popd exit

Save that file giving it a name you want but make sure it ends in .cmd

Next in Opus go to customize mode and create a new button. Set that button up like the one in the screen grab below. You will need to change "D:\Mine\cmd\Test.cmd" in my example to the full path of the text file you created up above. Exit customize mode, go to a test folder with some unwanted .exe files and give it a try.

I think I'd want it to make sure it didn't overwrite any existing .txt files, but maybe that isn't an issue in this scenario.

FWIW, you could do a similar thing using just Opus commands. (Which would give the advantage of working with Unicode paths, which I'm guessing a DOS .cmd file won't handle. I don't know if that is important here, though.)

I don't think I understand the scenario enough to suggest a better solution. Wouldn't one text file listing the EXEs that used to exist do as good a job as dummy text files in the filesystem? What's the real aim here? Saving disk space? What will be done with the dummy text files in the future? Is there anything else in the directories with the text files?

Hi John,

thanks a lot for your script. I tried it out with some test files and it's working. One small thing I'd like to change: when deleting the exe files , they should first go in the dust-bin. Is this possible?

Kind Regards!

launchee as far as I know batch files won't delete to the recycle bin without using some special software that's designed to do it. So instead what I'd do would be to move the exe files to a folder you've created. Then you can use Opus to delete the exe files to the recycle bin. At the moment I'm not in a location where I can change the batch file to do that for you, so I'll do a follow up post in 2 or 3 hours when I'll be home again.

Leo I must have missed something. At first I tried to do this project totally with Opus commands but I hit a wall when it came to creating the zero byte txt files in the same subfolder locations as the original exe files. If you have some free time, can you tell me how you would do that?

I had a kludge in mind where it'd create an empty file somewhere and then copy it as needed.

(I'd still be tempted to use VBScript instead, FWIW.)

Ah, I never thought about going the kludge route. :wink:

Launchee here's a revised version of the script. Instead of deleting the exe files it will move them to a different folder where you can later delete them to the recycle bin with Opus. In my script the folder I'm moving the exe files to is called

C:\my trash\

You will either need to create a folder with the same name, or change the script where it says "C:\my trash" to be the full path to the folder you want to move the exe files to.

@echo off if not "%OS%"=="Windows_NT" exit if {%1}=={} exit pushd %1 for /r %%a in (*.exe) do ( type nul>"%%~dpa%%~na%%~xa.txt" move "%%~a" "C:\my trash\" ) popd exit

Hi John,

thanks a lot and sorry for my late reply (was away).
Regards!