Sdel - speedy deletion utility

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Sdel - speedy deletion utility

#61 Post by foxidrive » 10 Jan 2016 11:02

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.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Sdel - speedy deletion utility

#62 Post by batchcc » 11 Jan 2016 14:29

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?

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Sdel - speedy deletion utility

#63 Post by foxidrive » 11 Jan 2016 16:27

batchcc wrote:how can I fix that issue?


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

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Sdel - speedy deletion utility

#64 Post by batchcc » 12 Jan 2016 16:04

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

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: Sdel - speedy deletion utility

#65 Post by Squashman » 12 Jan 2016 16:27

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.

Post Reply