2
0
I found this answer on Server Fault, but it is nearly 10 years old and doesn't work anyway
I have files with names like:
AlchBagSquare_Black°.nif
League-of-Legends-фэндомы-1759411.jpeg
When I attempt to use del {filename}
to delete them, it just says:
Could Not Find
{filename}
I need a single, comprehensive solution that will work for all special characters via the Windows 7 command line.
Edit: I am generating a batch file to delete files, so it also cannot require user input.
Edit 2: Here's how I am using the delete command:
del /F "D:\backup\League-of-Legends-фэндомы-1759411.jpeg"
1Have you tried
cd
ing into the directory containing the file(s), typedel
(note the space) and then cycle through the files using TAB repeatedly? – sticky bit – 2018-04-29T19:49:48.273@stickybit This will not work as I am generating a batch file to delete files, so it cannot require user input. – oscilatingcretin – 2018-04-29T19:51:05.503
Your question does not state that you are using a batch file, only command prompt. Please edit your question and provide every detail, or it will be hit-and-miss. I'm going to vote-close this as unclear what you're asking. – LPChip – 2018-04-29T19:54:01.710
Then maybe providing that batch within the question might help to help. – sticky bit – 2018-04-29T20:10:41.087
Both of you relax. I edited the question, and I wasn't downing you, @stickybit, for not being able to discern what I meant when there was a lack of information. – oscilatingcretin – 2018-04-29T20:12:59.040
1I am not able to recreate this on Windows 7 with both
echo y | del *.*
orfor %A in (*.*) do del %~A
for some reason on Windows 7 both ways deletes the files as per the example names you provided on my test Windows 7 system. Perhaps providing the exact logic of the batch script you are using will help others see if there is anything obvious at this level that may indicate what may be going on from your side? They were just frazzled by the ZZ Top beard.... lol – Pimp Juice IT – 2018-04-29T20:19:05.8871I edited the question with the command I am using. I think the reason why your loop and wildcards are working is because the command is interpreted and executed internally where it doesn't have issues with the encoding. However, when provinding a filename with special characters at the command level, it borks because the command prompt can't handle the encoding. And, yes, my beard tends to do that to people :) – oscilatingcretin – 2018-04-29T20:27:04.593
An encoding issue indeed seems likely. I tried writing a batch like that, and copied the full path from the Explorer address field. Once I did it with SciTE, which by my settings, uses UTF-8. Result: "Could not find ...". Then I did it with plain old Notepad. That worked. – sticky bit – 2018-04-29T20:46:30.360
Maybe the file is corrupt and it's not a 'special character' issue. If for some reason del isn't deleting a file then I wouldn't use just the command prompt. If this is a one off problem then just use a linux bootable os off usb and delete it from the linux command line. Really all you have for deleting a file in the cmd prompt is DEL or RM..and you're hostage to windows using the file or having some issue. If you want to stick to cmd maybe you could experiment a bit like Move to rename it then trying to delete it. You could try the windows recovery console that has a command prompt. – barlop – 2018-04-29T21:41:16.963