Asatoma Sadgamaya
asked on
DOS command to delete particular file/s from a folder
Hi,
I am looking for dos command to force delete file/files by its name from folder. No matter any user uses/open that file. I don't want all files in the foleder get deleted when I run this code. Thats the reason why I am asking for a code where I can put file names and that code will delete the files I needed.
Thank you
I am looking for dos command to force delete file/files by its name from folder. No matter any user uses/open that file. I don't want all files in the foleder get deleted when I run this code. Thats the reason why I am asking for a code where I can put file names and that code will delete the files I needed.
Thank you
hmm, there are no users in DOS..
Pretty sure OP means CMD and not DOS
I would however use Powershell, somehing like this
I would however use Powershell, somehing like this
Get-SmbOpenFile | Where-Object -Property sharerelativepath -match "SomeFile.txt" | Close-SmbOpenFile -Force
Get-ChildItem -Path C:\Temp -Include "SomeFile.txt" -File -Recurse | foreach { $_.Delete()}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
- What kind of file is it?
- What program is used to open it?
- Does the file reside on a server?
Some programs lock the file when it is opened, possibly preventing it from deletion
Servers can use the NET FILE or PSFILE command to force closure of shared files