Under Windows, there are certain types of files that can be "deleted" while they are in use (meaning that the programs that are using this file via a file handle, continue to use it even though no new program who wants to start access to this file can do it because after the "delete" no name exists in the file system, a .exe or a .dll file for example). A .jpg file is not one of those types of files.
So if you don't care whether this file gets deleted or not,
perhaps:
#!/usr/bin/perl -w
use strict;
foreach my $file (glob "*.txt")
{
unlink $file or print "unable to delete $file\n";
}
To delete a file that is in use, register a
Run Once program or script. This requires a reboot.
Perl "unlink" can do things that you cannot do from another Windows command line window, e.g. "delete" a .dll, etc.