search in files with strange characters


cokedude

Active member
Member
Local time
7:16 PM
Posts
61
OS
10 and 11
Normally windows can search in files. Some programs add a `~` to the beginning of backup files. I would like to search in these files. Is this possible? Windows seems to have issues searching in these files.
 

My Computer My Computer

At a glance

10 and 11
OS
10 and 11
Computer type
Laptop
Tilde (~) is a reserved character in the query language. You need to escape it, something like:
Code:
file:~"~*"

1733890273358.webp
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Try this batch script code it searches string in *.txt text files on current directory.

Code:
@echo off
setlocal enabledelayedexpansion

set /p "searchString=YOUR_STRING_HERE"


for %%F in (*.txt) do (
    findstr /c:"%searchString%" "%%F" >nul && echo Found: %%F
)


pause
 

My Computer My Computer

At a glance

Windows 11AMD Ryzen 7 5700GMicron Technology DDR4-3200 16GBNVIDIA GeForce RTX 3060
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
HP Pavilion
CPU
AMD Ryzen 7 5700G
Motherboard
Erica6
Memory
Micron Technology DDR4-3200 16GB
Graphics Card(s)
NVIDIA GeForce RTX 3060
Sound Card
Realtek ALC671
Monitor(s) Displays
Samsung SyncMaster U28E590
Screen Resolution
3840 x 2160
Hard Drives
SAMSUNG MZVLQ1T0HALB-000H1

My Computer My Computer

At a glance

10 and 11
OS
10 and 11
Computer type
Laptop
Try this batch script code it searches string in *.txt text files on current directory.

Code:
@echo off
setlocal enabledelayedexpansion

set /p "searchString=YOUR_STRING_HERE"


for %%F in (*.txt) do (
    findstr /c:"%searchString%" "%%F" >nul && echo Found: %%F
)


pause

So in this case I just create a batch file then put the batch file in the directory I want to search? Is there a way to update this to specify the folder I want?
 

My Computer My Computer

At a glance

10 and 11
OS
10 and 11
Computer type
Laptop
Like this 248294 file:~"~*"? Wanna search for the number 248294.
Strange...

1. You can separately search for text string 248294 in files.
2. Or you can separately search for filenames matching "~".
3. But you can't do both at the same time.

I found a PowerShell scripting example which uses the Windows Search API, to see if it's a limitation on the Explorer UI. And it's not, the PS script has the same problem. For some reason, you're not allowed to do both.

So I modified the script to just find "~" files that are indexed already, and then manually search those known files for instances of a search string. You don't need to specify a path, it's querying the Search Index for whatever has been indexed.

Code:
C:\Users\GARLIN\Downloads>WinSearch.bat 248

C:\Users\GARLIN\Documents\~249cef99eee94q.tmp
=============================================
This is a line with 248294 in it.

C:\Users\GARLIN\Documents\~NEW
==============================
248 248 248
 

Attachments

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Look outside the Window ... go freeware
- Everything
- Ultrasearch
- Agent Ransack
 

My Computers My Computers

  • At a glance

    Windows 11 2xH2 (latest update ... forever anal)Intel i5-124008GBNVIDIA GeForce GT730
    OS
    Windows 11 2xH2 (latest update ... forever anal)
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Slim S01
    CPU
    Intel i5-12400
    Memory
    8GB
    Graphics Card(s)
    NVIDIA GeForce GT730
    Sound Card
    OOBE
    Monitor(s) Displays
    Acer 32"
    Screen Resolution
    1920x1080
    Hard Drives
    512GB KIOXIA NVMe
    1TB SATA SSD
    PSU
    OOBE
    Case
    OOBE
    Cooling
    OOBE
    Keyboard
    BT
    Mouse
    BT
    Browser
    Brave FFox Chrome Opera
    Antivirus
    KIS
  • At a glance

    Windows 11 Pro 2xH2 (latest update ... 4ever ...i7-1165G7 @ 2.80GHzIntel Iris Xe Graphics
    Operating System
    Windows 11 Pro 2xH2 (latest update ... 4ever anal)
    Computer type
    Laptop
    Manufacturer/Model
    HP Pavillion 15
    CPU
    i7-1165G7 @ 2.80GHz
    Graphics card(s)
    Intel Iris Xe Graphics
    Hard Drives
    Samsung NVMe 512GB
    + numerous/multiple SSD Type C USB enclosures
    Internet Speed
    NBN FTTN 50
    Browser
    Brave
    Antivirus
    KIS
Back
Top Bottom