How to Search Code String in PHP Files in Windows XP
If you have Windows XP on your PC I bet you have problem finding files by contents. Let us try an experiment. I created an "all_mysites.txt" text file in the notepad with all my web sites URLs and short descriptions and save it in "C:\search" directory. Hover mouse over a thumbnail to see a large image.
Inside "C:\search" folder I created subdirectory: "subfolder" Then I copied "all_mysites.txt" file in subfolder directory also.
I opened My Computer and then opened C: drive. From main menu, I selected View, Explorer Bar, Search. In the field "A word or phrase in the file:" I typed words "Web tutorials" and clicked Search button
The all_mysites.txt file was found by Windows. Now I will show you a mistery. I rename all_mysites.txt file to all_mysites.php and repeat the same search procedure. See picture below.
This time no files found!
How come? What is wrong? I do not know. I suspect it is a bug. I tried different extensions and discovered that windows search does not work for .xls files as well. It works for .doc, .html, .xml.
What upsetting for me is that it is not working for .php files and I need it badly, because I develop web sites in PHP. Is there a work around? Fortunately, there is. And I will share it with you.
Open command prompt. To get to C:\ drive type "cd.." and press enter two times. Then type "cd" search to get to "search" directory. In the search directory type command: "findstr /s" then search string: "Web tutorials" then "*.* The '/s' means search in the directory and all subdirectories For files with contents matching the search string. See Picture below:
Both files "all_mysites.php" are found.
You can use many different flags with findstr command. See Windows help for complete list. "/o" flag displays offset: number of characters from the beginning of the file to matching string.
C:\search>findstr /s /o "Web tutorials" *.*
all_mysites.php:22:Web tutorials and
subfolder\all_mysites.php:22:Web tutorials and
"/n" flag displays matching line number
C:\search>findstr /s /n "Web tutorials" *.*
all_mysites.php:2:Web tutorials and
subfolder\all_mysites.php:2:Web tutorials and
"/i" makes search not case sensitive. You can use many flags at once
C:\search>findstr /s /o /i "photo" *.*
all_mysites.php:185:Photo related productssubfolder\all_mysites.php:185:Photo related products
Use mkdir command to create a directory. Create aFolder and bFolder inside the search folder. Type:
seatch> mkdir aFolder
seatch> mkdir bFolder
Place some files in aFolder directory using Windiws Explorer and then use xcopy command
to copy files from aFolder directory to bFolder directory.
Type in command prompt: xcopy aFolder bFolder. All files from aFolder directory will be copied to aFolder directory.
To see a directory tree, use tree command. To limit output of tree command by one command prompt window, use '| more' command.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\sergey>tree | more
Folder PATH listing
Volume serial number is 0006EEA4 507D:DD9F
¦ ¦ +---control
¦ +---Corel on the Web
¦ +---Microsoft Web Sites
¦ +---Microsoft Websites
-- More --
Press enter to display one more line, or press space bar to display the next window.
By the way, the same command is used in unix.
Do you want to learn more how to use command prompt - see Windows help. It is worth to know!
Please rate the tutorial
- Batch Files
- Java Properties
- Form Validation
- Display Image PHP
- Upload File PHP
- Environment Variables
- Delete Trojan horse
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn SQL
- Learn PHP
- Learn C++
- Learn Java
- Learn Visual Basic
- Web Site Tips
- Virtual Server
- User_Auth. Demo
- My Best CSS Layout
- CSS Tables
- PHP + Oracle
- Using Twitter
- Set Shopping Cart
- Advertise here
- Site map