This works del C:\Users\MLM\Downloads\TEST DEL *.zip *.txt *.doc *.jpg *.exe *.pdf /q /f
but when I put the same command on another pc it says the Path could not be found
del "E:\PC1-HOME\export\corrupted\*.*" /q planning to modify it for a specific file to be deleted so I make something like this del "E:\PC1-HOME\export\corrupted\*.xml *.zip" /q not working I tried to remove the \ del "E:\PC1-HOME\export\corrupted *.xml *.zip" /q
File could not be found......... Wht is wrong with this command it is OK in one PC then error on the other PC
Specific Multiple delete
Moderator: DosItHelp
Re: Specific Multiple delete
try this one
change YOUR DRIVE AND MAP into "E:\PC1-HOME\export\corrupted" and adjust the extensions you want to delete. Seperate extensions with a ,
Code: Select all
for /r "YOUR DRIVE AND MAP" %%g in (*.xml,*.zip) do (del /q /f %%g)
Re: Specific Multiple delete
Try to change to the directory first:
Or:
Or:
Or:
Or:
Or:
Alternatively, use the absolute paths:
Code: Select all
CD /D "E:\PC1-HOME\export\corrupted" && (
Del /F /Q *.xml *.zip
)
Code: Select all
CD /D "E:\PC1-HOME\export\corrupted"
If ErrorLevel 0 Del /F /Q *.xml *.zip
Code: Select all
CD /D "E:\PC1-HOME\export\corrupted"
If %ErrorLevel% Equ 0 Del /F /Q *.xml *.zip
Code: Select all
PushD "E:\PC1-HOME\export\corrupted" && (
Del /F /Q *.xml *.zip
PopD
)
Code: Select all
PushD "E:\PC1-HOME\export\corrupted"
If ErrorLevel 0 (
Del /F /Q *.xml *.zip
PopD
)
Code: Select all
PushD "E:\PC1-HOME\export\corrupted"
If %ErrorLevel% Equ 0 (
Del /F /Q *.xml *.zip
PopD
)
Code: Select all
Del /F /Q "E:\PC1-HOME\export\corrupted\*.xml" "E:\PC1-HOME\export\corrupted\*.zip"
Re: Specific Multiple delete
Thank you soooooooo much
It helps
It helps
Re: Specific Multiple delete
gathered all your ideas I was able to construct something like this
cd /d "PC-1\J\export\corrupted\"
Del *.xml *.zip *.rar *.contact *.rtf *.rar
cls
pause
Thank you so much for your help
cd /d "PC-1\J\export\corrupted\"
Del *.xml *.zip *.rar *.contact *.rtf *.rar
cls
pause
Thank you so much for your help
Re: Specific Multiple delete
Why, did you not use the code I gave you?
Not only are you likely to get an error message, because you're trying to delete all .rar files after you've already delated them, but you've made a grave mistake too. If the directory change to PC-1\J\export\corrupted fails in any way, the next line is going to permanently delete all files in whatever remains as the current directory. Other than using the CD command with the /D option, you've learned absolutely nothing from what I posted in more than two weeks of me submitting it.
Re: Specific Multiple delete
Yes, I have noticed that for the unfortunate event, it could delete all in the directory if it could not find its intended path. Regarding the .rar just encoded it twice. For your could I have derived it to make it somewhat simple but all the given code snippets were saved by me to be used for a bigger project.Compo wrote: ↑02 Feb 2023 20:31Why, did you not use the code I gave you?
Not only are you likely to get an error message, because you're trying to delete all .rar files after you've already delated them, but you've made a grave mistake too. If the directory change to PC-1\J\export\corrupted fails in any way, the next line is going to permanently delete all files in whatever remains as the current directory. Other than using the CD command with the /D option, you've learned absolutely nothing from what I posted in more than two weeks of me submitting it.
Thank you so much for your effort for giving me the sample code I just used the simple one so easy to trace the error in the script I have created