Page 5 of 5

Re: Sdel - speedy deletion utility

Posted: 10 Jan 2016 11:02
by foxidrive
batchcc wrote:but the code doesnt work on my computer Foxdrive

Code: Select all

H:\1\A\del>(if /I not "Delete.bat" == "sdel!random!.sdel" for %g in ("sdel!random!.sdel") do


The line above shows you have a file called "sdel!random!.sdel" and it must have been held open and locked by some process, as the del command a few lines above it attempted to delete it.

Re: Sdel - speedy deletion utility

Posted: 11 Jan 2016 14:29
by batchcc
foxidrive wrote:
batchcc wrote:but the code doesnt work on my computer Foxdrive

Code: Select all

H:\1\A\del>(if /I not "Delete.bat" == "sdel!random!.sdel" for %g in ("sdel!random!.sdel") do


The line above shows you have a file called "sdel!random!.sdel" and it must have been held open and locked by some process, as the del command a few lines above it attempted to delete it.

how can I fix that issue?

Re: Sdel - speedy deletion utility

Posted: 11 Jan 2016 16:27
by foxidrive
batchcc wrote:how can I fix that issue?


Delete that file. Or reboot your machine and try the script.

Re: Sdel - speedy deletion utility

Posted: 12 Jan 2016 16:04
by batchcc
Okay, thank you Foxdrive, I realized the file I was trying to delete was read only. I do have another question about this code though I can’t seem to make it work

Code: Select all

if "%~1"=="/e" goto ext
:ext
if "%~2"=="" (
   set /p d=enter path of folder to delete:
) else (
   set "d=%~2"
)
if "%~3"=="" (
   set /p d=enter extension:
) else (
if "%~3"=="-f" goto mfile
   set "ext=%~3"
)
if "%~4"=="" (
   set "extp=%~4"
)
goto skip
:mfile
set "%~4"="mfile"
cd /d %d%
FOR %%a IN (*.*) DO (
IF NOT %%a==%mfile%
setlocal EnableDelayedExpansion
if not "%~nx0"=="%%a" ren "%%~a" "sdel!random!.sdel"
goto next

:skip
cd /d %d%
setlocal EnableDelayedExpansion
for %%a in ("*.%ext%" "*.%extp%") do (
if not "%~nx0"=="%%a" ren "%%~a" "sdel!random!.sdel"
:next
for %%a in (*.sdel) do type nul > %%a
del *.sdel
)
:x

Re: Sdel - speedy deletion utility

Posted: 12 Jan 2016 16:27
by Squashman
Batchcc, you need to be more specific when asking for help. You always just say this does not work but provide no details about what does not work. You need to provide more detail. A lot of the problems we have helped you with were easy user errors that you could fix yourself if you just took a few minutes to step through the code. That is a hint. Read each line of code and decide if it makes sense.