DOS Command FindStr - command

I have a need to use the DOS command FINDSTR to search in all our source code files mixed with other types of files such as PDF, exe, dll, etc.
I do not need to search those binary files. Is there a way to exclude binary files?
My command looks like
findstr /r /n /o /s /g:c:\projects\vsssearch\muafinddata.txt /d:c:/projects/axl *.axl > output.txt
Thanks in advance for any insight.
John

Do yo try /p? Help says: "/P Skip files with non-printable characters."

Related

Windows script to merge all .html files in a directory and its subdirectories into a single .html file?

I have a Results directory, which has many subdirectories each containing a HTML file with a specific naming format, _ExeReport.html.
I want to write a Windows script which merges each of those files into one file.
For now, I tried running two commands :
dir /S *_ExeReport.html
This is listing all the files (with some extra information), and:
copy /b *.html final.html
This is merging all the files in current directory into one file.
But, I am not able to write a script which can combine and do everything I need.
Can someone help me with this? I am newbie to scripting languages.
Thanks to #T3RR0R for sharing the link. My final command :
FOR /F "tokens=*" %G IN ('dir /b /s *_ExeReport.html') DO TYPE "%G" >> MergedOutput.html

How do I use Command Prompt to Find only execuatable files in drive C

I need to search for possible virus in drive c. I believe it is in .exe format.
Please advice on how to use command prompt to achieve this.
This will give you a list of exe files.
dir c:\*.exe /s >"%userprofile%\desktop\exelist.txt"
The above will not search all dirs/folders, try cd %userprofile%
and then
for /r /d %G in ('*.exe') DO echo Found Exe : %I

7zip command line synthax using wildcard

Based on this source, the following should work for the 7zip command line tool:
7zG a -tzip "C:\20131024_archive.zip" "C:\archive" *20131024*
The goal is to zip all the files containing the date in the name. However, this is not working for me as it zips all the files without the date filter.
I've tried all sorts of variants without success. What am I doing wrong?
It turns out the date filter goes into the target filename like so:
7zG a -tzip "C:\20131024_archive.zip" "C:\archive\*20131024*"
Just use forfiles if your using windows 7. Type forfiles /? for more info. A think this will do what you want:
pushd C:\archive
forfiles /m "*20131024*" /c "7zG a -tzip C:\20131024_archive.zip #file"
I'm not sure this will work if the file name has spaces.

How to delete files from a list?

I have a filesystem that uses a hash algorithm to organize files. I have used xcopy in the past to copy files to a different location by passing in a file that has a list of all the files and having it iterate through it. The script looks similar to the following:
for /f "delims=, tokens=1,2,3" %i in (D:\foo.csv)
do echo F | xcopy /i /d "Z:\%i\%j\%k" "Y:\%i\%j\%k" >> "D:\xcopy\Log.txt"
However, now I've run into a situation where in addition to copying the files that are provided in the foo.csv file, I want them to be deleted as well. I looked at the xcopy documentation and couldn't find anything. Is there someway I can accomplish this, even if I have to run another script to go through the same list of files and delete them after using xcopy?
Thanks!
You can use parenthesis to indicate multiple commands to be excecuted by the for operand:
for /f "delims=, tokens=1,2,3" %%i in (D:\foo.csv) do (
echo F | xcopy /i /d "Z:\%%i\%%j\%%k" "Y:\%%i\%%j\%%k" >> "D:\xcopy\Log.txt"
del /F "Z:\%%i\%%j\%%k"
)
I'm not familiar with Windows (I'm happily using Gnu/Linux since 1993), but perhaps you could add some command with variables like del %n somewhere (or replace xcopy with your own .bat file doing what you want)
From the look of it you can use move command instead of xcopy, since you're not using any extended features from xcopy. The '/d' is supposed to be used to only copy the files if they are newer, not sure how useful that is for your purpose since you want to delete them. Otherwise, move doesn't have many more options to speak of.
Another possible, and slightly more sophisticated, method is robocopy.
robocopy /MOVE /XO "Z:\%i\%j\%k" "Y:\%i\%j\%k"
The /MOVE would delete both folders and files after copying, and /XO flag excludes older files from being copied. robocopy is primarily available in newer operating systems (i.e. Not XP). You can check the above mentioned reference for more details.
Hope this helps. Although, just using del as previously mentioned should work fine also.

Making batch file for copying

Can anyone advise me please im using Windows XP Pro on C drive and need to be able to copy a file from one drive to another. This case original will have to be renamed and old file must be put on another Partiton which is on a Server Example K drive.
Alternately There is another option using Windows 7 on a another computer instead of Windows XP Pro. So any answers appreciated.
A quick look on my old DOS book that I saved just in case that I have to make batch files says COPY is the right command.
Syntax:
COPY DRIVE:FILENAME DRIVE:FILENAME
COPY THISFILE THATFILE
If your permissions are setup to allow copying, you can use "UNC" paths to copy files across servers and drives.
Like Noah said, check out ROBOCOPY or the slightly less featured XCOPY.
Enter copy /? or xcopy /? to find out the available options - if you append >file.txt you'll get them in a text file.
XCOPY Command:
xcopy c:\sourceDirectory\*.* d:\destinationDirectory\*.* /D /E /C /R /Y
ROBOCOPY Command:
robocopy c:\sourceDirectory\*.* d:\destinationDirectory\*.* /R:5 /W:3 /Z /XX /TEE
Either of these should work for you
Have you looked into robocopy?