As for the quest
aGerman wrote: ↑02 Sep 2022 05:39
[...]
To achieve your original request
[...]
then if the whole script is suppose to look literally like this
Code: Select all
@if (0)==(0) echo off
:: ^^ Always the first line in the script.
:: This navigates to the folder containing the executable file and then runs it. So this simply opens the software
for /f "tokens=1-6 delims=|" %%i in ('cscript.exe //nologo //e:jscript "%~f0"') do (
REM take only the recycle bin of drive D: into consideration
if /i "%%~dj"=="D:" (
REM handle files and directories separately
if "%%i"=="F" ( REM file
REM doDelete is used like a flag; any value assigned to it is treated as "true"; initially it is explicitely undefined which is treated as "false"
set "doDelete="
REM any file with a different extension than those used in the IF chain will be marked for deletion
if /i not "%%~xk"==".MP3" if /i not "%%~xk"==".FLAC" if /i not "%%~xk"==".APE" set "doDelete=1"
REM any file being longer than 66 days in recycle.bin will be marked for deletion (regardless of the file extension)
if %%m gtr 66 set "doDelete=1"
REM check the doDelete marker, and either delete or keep the file
if defined doDelete del "%%j"
) else ( REM directory
REM always delete directories
rd /s /q "%%j"
)
)
)
echo(
pause
:: vv Always the last lines in the script.
goto :eof @end
var FMTID_Displaced = '{9B174B33-40FF-11D2-A27E-00C04FC30871}', PID_DISPLACED_FROM = '2', PID_DISPLACED_DATE = '3', msInDay = 86400000,
ssfBITBUCKET = 0xa, colItems = new ActiveXObject('Shell.Application').Namespace(ssfBITBUCKET).Items(), i = 0, objItem;
for (; i < colItems.Count; ++i) {
objItem = colItems.Item(i);
WScript.Echo((objItem.IsFolder && objItem.Name.slice(-4).toLowerCase() !== '.zip' ? 'D' : 'F') + '|' +
objItem.Path + '|' +
objItem.ExtendedProperty(FMTID_Displaced + PID_DISPLACED_FROM).replace(/\\$/,'') + '\\' + objItem.Name + '|' +
Math.round((new Date() - new Date(objItem.ModifyDate)) / msInDay) + '|' +
Math.round((new Date() - new Date(objItem.ExtendedProperty(FMTID_Displaced + PID_DISPLACED_DATE))) / msInDay) + '|' +
objItem.Size);
}
then it does not work; because it only sees in
Recycle Bin of drive
D only few graphics related files omitting whole bunch of other items]- and even for those it spits out
Access is denied error. And these errors are manifestation of those
DOSadnie wrote: ↑23 Aug 2022 12:20
[...]
some issues with the
Recycle Bin throughout iterations of Windows
[...]
that I mentioned in my initial post. To combat them I tried running
BAT file with this script as Administrator, both with
Run as Administrator applied to the file itself from the shell menu and to a
LNK shortcut leading to it - and that second trick I use in order to successively run that overall script of mine
DOSadnie wrote: ↑23 Aug 2022 12:20
[...]
Code: Select all
rd /s /q c:\$Recycle.Bin
rd /s /q d:\$Recycle.Bin
rd /s /q e:\$Recycle.Bin
[...]
[thus it should make the
BAT work but somehow it does not]