• Update - Using Powershell
:
Get-childitem -re . | Where-Object {$_ -NotMatch '(?:®)'}|remove-item -recurse -force -Confirm:$false
# Or, by using alias #
gci -re . | ? {$_ -NotMatch '(?:®)'}| rd -re -force -Confirm:$false
• There also, can be more short cmd/bat:
:: in command line ::
chcp 1252 >nul & for /f "tokens=*" %i in ('dir /a:-d /b /s *.zip ^|find /v "®"')do echo=del /q /f "%~fi"
:: in cmd/bat file ::
@echo off && >nul chcp 1252
for /f "tokens=*" %%i in ('dir /a:-d /b /s *.zip ^|find /v "®"')do echo=del /q /f "%%~fi"
- My previous answer with whose probable use is doubtful, but work too!:
@echo off & >nul chcp 1252
for /f "tokens=*" %%i in ('dir /a:-d /b /s *.zip')do (
echo/"%%~i"|find "®">nul||echo=del /q /f "%%~fi" )
Or in commandline ::
>nul chcp 1252 && for /f "tokens=*" %i in ('dir /a:-d /b /s *.zip')do @echo="%~fi"|find "®">nul||@echo=del /q /f "%~fi"
Obs.: To add ® in your code, try...
- Press and holding the alt (left) + (num pad) 1 6 9
Maybe this can help?
In fact the special console character, where it activates the page and encodes it used to write / read the file name, and moves that information to variables, read and compare it all in alphabet soup, is a bit difficult to handle in cmd/bat, which is why I asked for help for a language...
Therefore, for a paranoid proposal, considering actions for delete files, I took C# to try implemented a comparison using base64 for string (wildcard alt 169 = ®).
- Obs.:
169 = ®
and differs from the 0169 = ©
The resulted from these actions, is a script cmd/bat, that at run time compiles the one C# sources into a executable, that will be used by script, to get string from file name, whether the character name is present (in base64) in the name.
Is this my friend, or, is something completely different from exposed above, and, that my English limited prevent me to explain to you clearly :)
@echo off && setlocal EnableExtensions EnableDelayedExpansion & chcp 1252 1>nul
cd /d "%~dp0" && set "_.net=%windir%\Microsoft.NET" && title >nul && title Q1500545
set "_arg=/t:exe /out:"%temp%\b64.exe" "%temp%\b64.cs" /platform:anycpu /unsafe+ /w:0 /o"
set "_here=." type nul >"%temp%\b64.cs" && set "_b64=%temp%\b64.exe" && >"%temp%\b64.cs"^
(
echo/ using System^;namespace b64 ^{class Program ^{static void Main^(string[] args^)
echo/ ^{if ^(args.Length ^> 1 ^&^& args[0] ^=^= "-e" ^| args[0] ^=^= "-E"^)
echo/ ^{byte[] plainTextBytes ^= System.Text.Encoding.UTF8.GetBytes^(args[1]^)^;
echo/ Console.Write^(System.Convert.ToBase64String^(plainTextBytes^)^)^;
echo/ ^}else if ^(args.Length ^> 1 ^&^& args[0] ^=^= "-d" ^| args[0] ^=^= "-D"^)
echo/ ^{byte[] base64EncodedBytes ^= System.Convert.FromBase64String^(args[1]^)^;
echo/ Console.Write^(System.Text.Encoding.UTF8.GetString^(base64EncodedBytes^)^)^;
echo/ ^}^}^}^}
)
for /f delims^=^ eol^=* %%i in ('%__APPDIR__%where.exe /r "!_.net!" "csc.exe"^|findstr /li k\v2\.
')do "%%~i" !_arg! /nologo && cd /d "%~dp0" && goto :^?
:^?
for /f delims^=^ eol^=* %%i in ('%__APPDIR__%where.exe /r "." "*.zip"')do call :^[ %%~fi
(for %%D in (exe,cs)do del /q "%temp%\b64.%%D") & endlocal && exit /b
:^[
for /f tokens^=* %%a in ('"cmd /u /c echo=%~1|find /v """
')do "!_b64!" -e %%~a|findstr "wq4=" >nul && exit /b )
echo/del /f /q "%~1" && exit /b
- My directory tree for test in
G:\SUPER_USER\Q1500545
:
G:.
¦ Q1500545.cmd
¦
+---Sub_Dir_01
¦ test_º.zip
¦ test_¿.zip
¦ test_®.zip
¦
+---Sub_Dir_02
¦ test_®.zip
¦ test_º.zip
¦ test_¿.zip
¦
+---Sub_Dir_03
¦ test_®.zip
¦ test_º.zip
¦ test_¿.zip
¦
+---Sub_Dir_04_®
test_®.zip
test_º.zip
test_¿.zip
- My script results by
echo/del /f /q "%~1"
:
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_01\test_º.zip"
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_01\test_¿.zip"
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_02\test_º.zip"
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_02\test_¿.zip"
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_03\test_º.zip"
del /f /q "G:\SUPER_USER\Q1500545\Sub_Dir_03\test_¿.zip"
using System;
namespace b64
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 1 && args[0] == "-e" | args[0] == "-E")
{
byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(args[1]);
Console.Write(System.Convert.ToBase64String(plainTextBytes));
}
else if (args.Length > 1 && args[0] == "-d" | args[0] == "-D")
{
byte[] base64EncodedBytes = System.Convert.FromBase64String(args[1]);
Console.Write(System.Text.Encoding.UTF8.GetString(base64EncodedBytes));
}
}
}
}
- My command line used to compile code
C#
:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /t:exe /out:"%Temp%\b64.exe" "%Temp%\b64.cs" /platform:anycpu /unsafe+ /w:0 /o