how to limit search to certain folder AND certain file types (more than one) in visual studio code? - visual-studio-code

consider the following files and folders structure:
head.html
folder1
1.css (this file is inside "folder1")
1.html
1.php
folder2
1.css
1.html
1.php
subfolder2 (this is a subfolder inside "folder2")
1.css
1.html
1.php
deepsub2 (a folder inside "subfolder2" that is inside "folder2")
1.css
1.html
1.php
to clarify the structure:
"folder1", "folder2", "subfolder2" and "deepsub2" are folders.
all the rest are files.
"1.css", "1.html" and "1.php" under that appear under a folder, for example "folder1" are inside
that folder.
"head.html" is in the root folder.
"subfolder2" is a folder inside "folder2" and "deepsub2" is a folder inside "subfolder2".
What i'm trying to do is search the word "viewport" in "folder2" and anything beneath it (including its subfolders), which means I don't want search in other folders (folder1 for example) or the root (head.html for example)
I also want to limit the search for file types: .html and .css
I DON'T want to specifically exclude .php as a file type because consider that sometimes I don't know what other file types there are in the structure and they can be t0o many to exclude, so I want to only to use a list of file types to include rather.
after reading the docs: https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options
the best I could come up with is using the following in the "files to include" input:
./folder2/**/*.css,./folder2/**/*.html
but it doesn't seem efficiant enough because i'm using the "folder2" path part for every file type.
is there a better way?
I'm using VScode Version: 1.65.0 by the way

This should work:
./folder2/**/*.{css,html} NO spaces in the {...} extensions or it won't work
from https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options:
{} to group conditions (for example {**/*.html,**/*.txt} matches
all HTML and text files)

Related

How to rename an XML file using the pattern in a different .txt file?

I have a folder say, source folder, containing 1000+ xml files with some ambiguous names, like:
_MIM_15646432635_6664684
_MIM_54154548557_6568436 etc.
Out of these thousands of XML files I’ve to select some 10-12 xml files with a particular node in them and move them to another folder (destination folder) and rename the files respectively with some meaningful names.
For example:
There is an xml file with name _MIM_15646432635_6664684 and it contains a node pattern like: “bab6e7h835468eg” and I’ve to rename it to name like: {1FE9909E-4450-B98665362022}
So for this I’ve to write a script which will search the file in source folder and if it finds my desired node pattern then move this file to destination folder post renaming it to some meaningful name.
Provided I’ve an excel sheet where I do have a list of two columns, one containing the specific node pattern and column two has a respective new name list.
Currenty, I’ve a script which can search a file and move it to another folder provided I’m giving input to the script with the node pattern and file name from that excel sheet:
Select-String – Path “\Dubwta01\AIR\Invalid*.xml” – Pattern ‘bab6e7h835468eg’ | %{Copy-Item – Path $_.Path – Destination ‘\Dubwta01\AIR\Invalid{1FE9909E-4450-B98665362022}.xml’
What now I need is that a new script which will pick all 10 files from source folder and move it to destination folder by renaming it and I don’t have to hard code the pattern and new name in script rather it shall fetch the details from that excel or I can save the details in text files whatever is suitable for script to pick the name and pattern from.

How to move files whose file name is not used in a set of text files?

I'm a Powershell beginner and this is my first post on stackoverflow. I can understand some simple pipelines, but the following challenge is too complicated for me at this point:
I have a folder with testdata containing *.bmp files and their associated files. I want a powershell script to check which bmp-files are still used. If not used, move bmp-files and associated files to another folder.
Details:
bmp-files and associated files: For example; car01.bmp, car01.log, car01.file, car02.bmp, (...)
The bmp-files are in use if their file name (eg, car01.bmp) is mentioned in any of the (text/csv) files in at least one of 2 locations (incl. subfolders).
If the file name is not found in any of the text files, I want the script to move that file, and any file who's name differs only by file extension to a designated folder.
Looking forward to your solutions!

How to search for files in different directories recursively in VSCode?

Visual Studio Code (as of version 1.41.1) is obviously very limited in regard of its file search. It seems to only allow to either search in folders recursively or in specific files, but it doesn't allow both.
Search in folders recursively
path/to/folder/ searches in any directories within subpaths matching path/to/folder including all subdirectories with no restriction in file names.
./path/to/folder/, ./path/to/another/folder searches in the directories with the paths path/to/folder and path/to/another/folder relative to the project's root directory.
Search in files
foo.bar searches in all files named foo.bar.
*.foo, *.bar searches in all files with the extensions foo or bar.
./path/to/folder/*/*.foo searches in all files with the extension foo that lie in a direct subdirectory of path/to/folder/ relative to the project's root directory.
Search in folders recursively and filter by file name
So, how to combine these two searches, i.e. filter the search by file names but search in specific directories with all their subdirectories?
In other editors like Eclipse you normally have two different fields for file names and folders, making it easy to specify them individually and avoid having to repeat yourself for multiple folders and file names. Therefore I have already created an enhancement request in the VSCode bug tracker asking to add a separate field for the folder.
In my testing, using the globstar does provide the functionality you desire.
https://github.com/isaacs/node-glob#glob-primer:
** If a "globstar" is alone in a path portion, then it matches zero
or more directories and subdirectories searching for matches. It does
not crawl symlinked directories.
So that ./path/to/folder/**/*.foo for example searches within all subdirectories of folder no matter how deep within files with the foo extension.
Same at https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options:
** to match any number of path segments, including none

list files under a directory excluding hidden files and without going through sub-folders

is there a way to list (NSLog) file names under a folder (named downloads that is located under the documents directory of my app) with the following conditions met:
1) exclude hidden files (such as .DS_Store files)
2) do not search in sub-folders (i do not want the enumerator to be recursive).
thank you so much in advance.
EDIT:
3) do not list sub-folders' names.
Use NSFileManager's enumeration with options and pass the appropriate flags, which are NSDirectoryEnumerationSkipsHiddenFiles and NSDirectoryEnumerationSkipsSubdirectoryDescendants
This is from the docs:

Issue with doxygen .dox files

I am trying to run doxygen on some source files for a project that I downloaded source files for. The files are located in the following directories:
doc/ - Documentation files, such as .dox files.
src/ - Source files
My settings in my doxygen.config file are:
INPUT = ../ .
FILE_PATTERNS = *.h *.dox *.dxx
When I run doxygen (doxygen doxygen.config), it generates all of the documentation from the .h files correctly, but it does not generate the mainpage correctly. I have a file titled intro.dox in the doc folder, with a command \mainpage Documentation Index, and a bunch of text, but doxygen is not using this to generate the main page.
What am I doing wrong?
There are (at least) two possible reasons for this:
You are not including the /doc directory in you INPUT list. Try modifying this to
INPUT = ../ . ../doc
Did you mean to write ../doc instead of ../? I am guessing that your doxygen.config file is in your src directory. If this is not the case can you make this clear in the question.
Doxygen requires that your documentation files (your .dox files) are plain text with your text wrapped with Doxygen C++ comments (i.e. /** ... */).
Without knowing where doxygen.config is located, and since you are using relative paths in INPUT, it is difficult to determine what might cause this, however since the files you are looking for are in parallel directories, it is possible that doxygen is not search recursively for your files. You may want to confirm that RECURSIVE is set to YES in doxygen.config.