I am trying to use find to look for files that contain a specific keyword. To my understanding, find takes in a file not a directory (that's why it is giving me error). So is there a way i can go through each sub-directories and look into each and every file to execute the find command so that I can get the result of all files that contains the given keyword? (Much like grep)
So far i got this:
find \S "keyword" "directory\ *"
Error i am getting:
Access denied - Directory name
Access denied - Directory name
.
.
.
Anyone give me a hint? I am current using window 7 right now.
FIND does not take the /s switch (not \s - that's a directory)
FINDSTR is another animal.
About the only quibble about the documentation avaliable from findstr /? from the prompt is that you can target a filemask in a specified directory by specifying \dirname\*, not simply in the current directory as documented. There is also an option to run against a semicolon-delimiter list of directory names - but I've never seen it used.
Related
I need to rename 80k files in multiple folders & subfolders in the same directory. I have been trying to use ren but have been unsuccessful; I get an incorrect syntax error.
My old name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\document_# (x.y.z)-test~.pdf
and my new name looks like this:
c:/users/alice/BiDIR_DOCS_2017_Nov08020423\Company,LLC##NA##7967425.00##7967425.00\Company LLC A and A - Aug2017.pdf BiDIR_DOCS_2017_Nov08020423\Company, LLC##NA##7967425.00##7967425.00\system, a old name~ ` to # system b document (xyz)-test.pdf
I have the existing directory print in one column of Excel and in the next column what I want the directory print to be.
I'm not sure if I'm starting my ren command at the right hierarchy of my directory, or if I need quotation marks to keep the spaces and symbols in my new name.
I have tried improvising and testing on my own without success and I cannot find an article online on point.
Try FAR (find and replace) - it a free utility that works well.
http://findandreplace.sourceforge.net/
I'm trying to install a grunt template on my computer but I'm having issues. I realized that perhaps something different is happening because of the path given by the Grunt docs, which is
%USERPROFILE%\.grunt-init\
What does that . mean before grunt-init?
I've tried to do the whole import manually but it also isn't working
git clone https://github.com/gruntjs/grunt-init-gruntfile.git "C:\Users\Imray\AppData\Roaming\npm\gru
nt-init\"
I get a message:
fatal: could not create work tree dir 'C:\Users\Imray\AppData\Roaming\npm\.grunt-init"'.: Invalid argument
Does it have to do with this /.? What does it mean?
The \ (that's a backslash, not a slash) is a directory delimiter. The . is simply part of the directory name.
.grunt-init and grunt-init are two distinct names, both perfectly valid.
On Unix-like systems, file and directory names starting with . are hidden by default, which is why you'll often see such names for things like configuration files.
The . is part of a directory name. Filenames can contain . . The \ is a separator between directory names.
Typically, files or directories starting with . are considered "hidden" and/or used for storing metadata. In particular, shell wildcard expansion skips over files that start with ..
For example if you wrote ls -d * then it would not show any files or directories beginning with . (including . and .., the current and parent directories).
Linux hides files and directories whose names begin with dot, unless you use the a (for "all") option when listing directory contents. If this convention is not followed on Windows, your example is probably just a carryover.
It may well be something behind the scenes (later) expects that name to match exactly. While I like things, installers, for example, to just do what I said, I realize that keeping default value is the most tested path.
Directories starting with a dot are invisible by default on xNIX systems. Typically used for configurations files and similar in a users home directory.
\ before " has a special meaning on windows, the error is because windows won't let you create a file containing " as part of its name.
I am copying a list of files using a prefix (i.e., ABCD*) to match files in a batch script. However, some files that appear to match are being left behind while other files that don't match are getting grabbed.
I ran a dir /X and found that the shortname for a handful of the files didn't match their longname:
4/17/2015 02:04 PM 554 ABCDEF~1.TXT abcdefghijklmnopqrs.txt
4/17/2015 02:08 PM 123 ABCDEF~2.TXT 1234567890.txt
4/17/2015 03:18 PM 233 987654~1.TXT abcdefg123456.txt
Any idea why something like this might happen and how to resolve it?
If your sample data is representative of your actual files, you could specify ABCDEFG* to workaround this issue.
EDIT
Since the above suggestion is not an option, you could use FSUTIL to remove all of the 8.3 names.
This command will analyze the files in the current directory (.) and display the changes without actually making them.
fsutil 8dot3name strip /t .
Remove the /t parameter to actually remove the 8.3 names.
You can also run:
fsutil 8dot3name strip
to see all of the options.
Short and long file names are not required to match. The default algoritm is documented here under "How NTFS Generates Short File Names". You can also find it in the wikipedia
You can change the short file name with
fsutil file setshortname longFileName shortFileName
I am writing a batch script which will copy a file from a folder into the C:\ drive:
#ECHO ON
COPY C:\RANDOMFILES\Weekly Reprort_Hew*.xls C:\Weekly Reprort_Hew???????????.xls
The filename in the RANDOMFILES folder is: Weekly Reprort_Hew, 6-29-2014 10-30-00 PM-642.xls (The date and time and the number at the end will always change so I used the * in the filename being copied in the script)
When I run the batch script, I get the following message:
c:\RANDOMFILES>COPY C:\RANDOMFILES\Weekly Reprort_Hewlett*.xls C:\Weekly Reprort
_Hewlett???????????.xls
The system cannot find the file specified.
How can I fix the issue?
You need double quotes to handle spaces etc. Double check the spelling too.
#ECHO ON
COPY "C:\RANDOMFILES\Weekly Reprort_Hew*.xls" "C:\Weekly Reprort_Hew???????????.xls"
Don't know why it is not working - is it hidden? Maybe the spaces in the name?
The following will work though:
FOR %%I in (C:\RANDOMFILES\Weekly Reprort_Hew*.xls) DO COPY "%%I" C:\
The destination file name isn't necessary; if not otherwise specified, it will remain unchanged provided the destination is different. That may be why the plain COPY command isn't working.
Also:
"It is an not-so-well-known fact that the question mark wildcard will match exactly one character only when the wildcard does not appear at the end of a file name. " from http://www.thefriendlycoder.com/2011/11/24/batch-file-gotcha-question-mark-wildcard/
I am dealing with a massive nest of files and need to find a .htaccess file that is redirecting a single page in my website. I know how ridiculous this sounds: why not just check the directories the page is located within? But the problem is slightly more complicated than that. All I need though, is to search for every .htaccess file under the web folder. Trying a normal search doesn't allow me to select that type of file to search for, and searching for hidden files has just been (who knows why) ignoring the .htaccess files anyway. I can't download any new software to do this for me. but - there must be a way! Even if I could somehow list every file within a directory (and its subdirs) and then organize by file type and scroll down?
I could search for any file with the word "RewriteEngine" , but there are so many files, this would take forever.
Any ideas?
Thanks!
=/ notepad++ is not installed, and I don't have auth to install anything
Use the commandline.
findstr /s RewriteEngine .htaccess
Searches the current directory and all sub directories for .htaccess files containing the string RewriteEngine.
Try searching for files of the form: *htaccess
(spelled precisely like that in the search field)
have you tried using Notepad++. It has a 'Find in files...' option that you could specify the page that it's trying to redirect to, and you could have it check only in *.htaccess files.
Just a thought
Search All files and folders, in All or part of the filename: put ".htaccess" including the quotes.
in the command prompt:
for hidden files: dir /s /b /a:sh *.htaccess>C:\results.txt
for non-hidden files: dir /s /b *.htaccess>C:\results.txt
to search for "RewriteEngine" type dir /s /b rewriteengine
both of these will output the search results to a text file called "results"