Delete file with special unicode char.
Moderator: DosItHelp
Delete file with special unicode char.
I searched on the internet and it seems i couldn't find solution. All i need is just delete file named 排名堡垒.txt using basic batch del command.
Re: Delete file with special unicode char.
Use the short file name.
Code: Select all
C:\BatchFiles\Kanji>dir /x
Volume in drive C is 13_06P
Volume Serial Number is 5AE4-90D0
Directory of C:\BatchFiles\Kanji
09/05/2014 03:27 PM <DIR> .
09/05/2014 03:27 PM <DIR> ..
09/05/2014 03:27 PM 0 C4B4~1.TXT ????.txt
1 File(s) 0 bytes
2 Dir(s) 256,937,218,048 bytes free
C:\BatchFiles\Kanji>del C4B4~1.txt
C:\BatchFiles\Kanji>dir /x
Volume in drive C is 13_06P
Volume Serial Number is 5AE4-90D0
Directory of C:\BatchFiles\Kanji
09/05/2014 03:29 PM <DIR> .
09/05/2014 03:29 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 256,937,218,048 bytes free
C:\BatchFiles\Kanji>
Re: Delete file with special unicode char.
Thank you Squashman that worked great on txt files, but i seem to have trouble with .url by using the same method.
Batch file is asking for permissions when i want to delete url files. (access denied, look at the picture below)
Is there any way to bypass it and delete?
Strange thing i can rename it, but even after rename - i can't delete it using batch file.

Batch file is asking for permissions when i want to delete url files. (access denied, look at the picture below)
Is there any way to bypass it and delete?
Strange thing i can rename it, but even after rename - i can't delete it using batch file.
Code: Select all
@echo off
rename 2014~1.url test.txt
del test.txt
pause

Re: Delete file with special unicode char.
The page could have been open in Chrome or a text editor or something else (except it's a shortcut - not sure)
Reboot the PC and try it again without opening any programs.
When it is appropriate you can also use del *.url in the directory.
You can also boot up a Linux live cdrom and use the file manager in Linux to remove the file.
Reboot the PC and try it again without opening any programs.
When it is appropriate you can also use del *.url in the directory.
You can also boot up a Linux live cdrom and use the file manager in Linux to remove the file.
Re: Delete file with special unicode char.
foxidrive, thank you for answer.
.url absolutely is shortcut to website.
del *.url is not working sadly, url file still here.
I restarted computer, and i'm sure no 3rd program is using the file.
I even tried del *.*
However, it also didn't help.
Both .url and renamed test.txt stayed in the folder. (all other files has been removed correctly)
I still have no idea how to remove it using batch so if anyone can give me any help, would be nice.
Also, i'm administrator of the computer, using Windows 8.1 x64 (but i think it is worthless information)
.url absolutely is shortcut to website.
del *.url is not working sadly, url file still here.
I restarted computer, and i'm sure no 3rd program is using the file.
I even tried del *.*
However, it also didn't help.
Both .url and renamed test.txt stayed in the folder. (all other files has been removed correctly)
I still have no idea how to remove it using batch so if anyone can give me any help, would be nice.
Also, i'm administrator of the computer, using Windows 8.1 x64 (but i think it is worthless information)
Re: Delete file with special unicode char.
foxidrive wrote:You can also boot up a Linux live cdrom and use the file manager in Linux to remove the file.
Download Ubuntu ISO image and write it to a disk and boot from that and use the file manager.
or for a smaller download you can download Puppy Linux and write it to a cdrom
http://www.puppylinux.com/download/index.html
Re: Delete file with special unicode char.
foxidrive wrote:foxidrive wrote:You can also boot up a Linux live cdrom and use the file manager in Linux to remove the file.
Download Ubuntu ISO image and write it to a disk and boot from that and use the file manager.
or for a smaller download you can download Puppy Linux and write it to a cdrom
http://www.puppylinux.com/download/index.html
Well, the faster way is just to drag and drop the file to recycle bin.

I can delete url files manualy. I just want to delete bunch of chinese url files automaticaly within one click. So that i didn't need to do that everytime and waste my time that much.
Also, thanks for answer.
Re: Delete file with special unicode char.
BoQsc wrote:Well, the faster way is just to drag and drop the file to recycle bin.![]()
I can delete url files manualy. I just want to delete bunch of chinese url files automaticaly within one click.
Then use this and right click on the batch file and run as administrator:
Code: Select all
@echo off
del *.url
You had at least me thinking that the filename had illegal characters in it which was stopping Windows from deleting it.
If that doesn't work then VBS can handle Unicode.
Re: Delete file with special unicode char.
foxidrive Look what happen in windows 8.1 when simple batch file with del command is run as administrator: (look below post)
And by mistake i pressed Y, and it started to delete all files from C:\Windows\system32\
But when i run without administration right - batch script is runing fine, except the url deletion, still can't do it.

And by mistake i pressed Y, and it started to delete all files from C:\Windows\system32\

But when i run without administration right - batch script is runing fine, except the url deletion, still can't do it.

Last edited by BoQsc on 06 Sep 2014 04:37, edited 1 time in total.
Re: Delete file with special unicode char.
I've tried WMIC query,jscript and filesystemObject , and wmi query through jscrit (didn't tried Shell.Application) - and didn't work.
What seems to work is deleting through jscript.net and list file where the file for deletion is recorded (and red with utf8 encoding):
I think you can go on from here and modify the script above to be suitable for you .Hope this helps.
Probably is still possible with windows script host or WMI but I didnt found a way.
What seems to work is deleting through jscript.net and list file where the file for deletion is recorded (and red with utf8 encoding):
Code: Select all
@if (@X)==(@Y) @end /****** silent line that start jscript comment ******
@echo off
del /q /f "%~n0.exe" && echo file deleted
::::::::::::::::::::::::::::::::::::
::: compile the script ::::
::::::::::::::::::::::::::::::::::::
setlocal
if exist "%~n0.exe" goto :skip_compilation
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
if exist "%%v\jsc.exe" (
rem :: the javascript.net compiler
set "jsc=%%~dpsnfxv\jsc.exe"
goto :break_loop
)
)
echo jsc.exe not found && exit /b 0
:break_loop
call %jsc% /nologo /out:"%~n0.exe" "%~dpsfnx0"
::::::::::::::::::::::::::::::::::::
::: end of compilation ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation
"%~n0.exe"
exit /b 0
****** end of jscript comment ******/
import System;
import System.IO;
import System.Text;
//F:\\scriptests\\list.txt has a single line containing F:\scriptests\排名堡垒.txt
var readText = File.ReadAllText("F:\\scriptests\\list.txt",Encoding.UTF8);
Console.Write( readText);
File.Delete(readText);
I think you can go on from here and modify the script above to be suitable for you .Hope this helps.
Probably is still possible with windows script host or WMI but I didnt found a way.
Re: Delete file with special unicode char.
That's a problem - but you wrote *.* instead of *.url
If it was *.url then it wouldn't have mattered.
This should get around the problem with the working directory.
If it was *.url then it wouldn't have mattered.
This should get around the problem with the working directory.
Code: Select all
@echo off
del "%~dp0\*.url"
pause
Re: Delete file with special unicode char.
npocmaka_ Thank you, i'm going to take a look at it later on.
):

Yep, i know that, it's my silly mistake.foxidrive wrote:That's a problem - but you wrote *.* instead of *.url
If it was *.url then it wouldn't have mattered.
Here is what i get (the same error like without administrator rights) i have no idea what's wrong (i'm 100% administrator, i even can delete system files thofoxidrive wrote:This should get around the problem with the working directory.Code: Select all
@echo off
del "%~dp0\*.url"
pause


Re: Delete file with special unicode char.
Try this - again by right clicking and run as administrator.
I'm assuming that the cmd prompt can handle these files - I don't have any to test with.
Code: Select all
@echo off
del "%~dp0\*.url" /a /f
pause
I'm assuming that the cmd prompt can handle these files - I don't have any to test with.
Re: Delete file with special unicode char.
%~dp0 contains a trailing back slash. Maybe you should remove it and use "%~dp0*.url" instead. Just a guess though.
Regards
aGerman
Regards
aGerman
Re: Delete file with special unicode char.
foxidrive, you are my hero! It works finaly. And it looks like with your code arguments there is no required for administrator privilegies.
Here is the example file i used for testing (if anyone need it later on): http://wikisend.com/download/229684/2014%E5%B9%B4%E5%85%A8%E9%83%A8%E7%83%AD%E9%97%A8%E5%8D%95%E6%9C%BA%E6%B8%B8%E6%88%8F%E5%8F%8A%E6%B1%89%E5%8C%96%E4%B8%8B%E8%BD%BD.url
The batch script that worked is here:
And this is working test with specific file name:
No need to run as administrator for both.
Thanks to everyone.
Here is the example file i used for testing (if anyone need it later on): http://wikisend.com/download/229684/2014%E5%B9%B4%E5%85%A8%E9%83%A8%E7%83%AD%E9%97%A8%E5%8D%95%E6%9C%BA%E6%B8%B8%E6%88%8F%E5%8F%8A%E6%B1%89%E5%8C%96%E4%B8%8B%E8%BD%BD.url
The batch script that worked is here:
Code: Select all
@echo off
del "%~dp0\*.url" /a /f
pause
And this is working test with specific file name:
Code: Select all
@echo off
dir /x
pause
del "%~dp0\2014~1.URL" /a /f
pause
No need to run as administrator for both.
Thanks to everyone.
