MS Graph API Search File Name not Content - api

I want to return a list of files within a folder on a OneDrive site that match a search pattern using MS Graph API.
The files can be up to a few levels deep in sub folders.
The files are named consistently, for example starting with the letters WKP. My searches always also return files that don't have WKP in the file name. I assume wkp is in the content somewhere for these files.
I can't find anything in the MS Graph docs that tells me how to search only the file names and not the content.
I am using this endpoint /v1.0/sites/{siteId}/drive/items/{ItemId}/search(q='WKP')
Is there a way to build the query so that it only looks at the file name? I tried q='filename:WKP'
Thanks,

Related

How to search full content of code files (e.g. SQL scripts) stored in a SharePoint folder?

Do you run into this situation that there are many code files (e.g. SQL scripts *.sql) stored in a SharePoint folder, and you need to run full text search to find a specific one containing certain keywords (a table/column/function name, a comment, someone's initials, etc)?
Problem here is the search function in SharePoint document library only looks at the filenames, not the full content.
Of course many code repo systems (e.g. BitBucket) have advanced full text search functions (e.g. definition over usage), but in this case SharePoint hosts the "code repo", and the business depends on it...
Through experiment I found out SharePoint search function actually looks at the full content of a few limited file types – plain text (.txt) and Word (.doc, .docx) files.
Since code files (*.sql, *.py, *.js, *.htm, *.css, etc) are essentially text files, we can "cheat" SharePoint by appending ".txt" to the filename (e.g. my_script.sql → my_script.sql.txt), making the file content searchable once indexing finishes (in the matter of seconds according to my test).
So if you manage a SharePoint folder of many code files, you can download the entire folder as a zipped file, unzip and modify all code filenames (with utility tools to do this in batch or run a DIY script), and re-upload... voila!

How to Create a Program Which Searches for Values from a .txt or any Text Document in Specific Folders

I am relatively new to programming and want to create a program which can solve a problem that I frequently have.
So here's the background to my short story: I was on a website which hosted many files (We're talking about around 500-1000 small files). I was then like," Oh sweet! I want to have all these things in my hard drive so I know that I have access to them... but am probably not going to use them either way". I proceeded to download all 500-1000 files on that site, but encountered a problem when I looked at the properties of my destination file. Let's say that out of 500 on the site, my computer only had 499 files. Just my luck. I wanted to know what was that one pesky file that slipped right by me and download that file specifically. What I didn't want to do was to delete all the files and then try my luck once more in downloading all the files from the website. On the site, there was no indication of what all files I downloaded, so I was completely in the blue. I could go in Ctrl+C each item, then Ctrl+V into the file manager search bar, but that would be tedious to repeat that 500 times.
Now, what I want to do: I wanted to go ahead and take all of the file names from the website (The file name that I downloaded and the file name that was in my drive are the same), put them all in a simple .txt document or something (The website has multiple unwanted text alongside the text I need, such as:
. If this is not possible to extract the text from the site like this, then I am ok with manually entering the names via copy paste). Then I want the computer to take these values in the document and then search for it in a specific folder path (Note: the actual files are in subfolders within the root folder I want to choose, so the program has to be able to search within multiple folders of the root). Then I want the computer to know if the value in the document, is present as a file. If the file doesn't exist, then I want that value/those values in the document to be displayed as the output. I want this cycle to repeat until all the values have been gone through. The output should list the values that were not present.
Conclusion: You probably now get at what I am trying to do, if you don't, tell me what I need to elaborate on. I really don't care how this program is made (what language or software), I just want something that works... but myself don't know how to create.
Thanks for reading and any response is appreciated!
Dhanwanth P :)
Here's a solution in Python in case you would like to explore...
Similar to what you described, all files from the website are listed in an Excel file 'website_files.xlsx'
And all files are saved in a folder 'downloaded_wav'. The script will work regardless the files are saved in the root directory or sub-folders.
Then I run below Python script to look for the missing file:
import pandas as pd
import os
path_folder = 'C:\\Users\\Admin\\Downloads\\downloaded_wav'
downloaded_files = []
d,m = 0,0
for path_name, subfolders, files in os.walk(path_folder): #include all subfolders
for file in files:
d+=1
downloaded_files.append(file)
df = pd.read_excel('website_files.xlsx')
for file in df.values:
if file not in downloaded_files:
print('MISSING', file)
m+=1
print(len(df), 'files on website')
print(d, 'files downloaded')
print(m, 'missing file(s) found')
Output:
MISSING ['OLIVER_snare_disco_mixready_hybrid.wav']
3 files on website
2 files downloaded
1 missing file(s) found
No worries; I found a solution by myself using Excel (God, it's powerful!).
Basically, I copied and pasted my values from the website, then used a filter to show the values only with .wav. Then I used a Power Query from the folder to get me a list of all names of files in a folder. Finally, I went ahead and compared the two using a formula:
=IF(COUNTIF(B:B,D,"OK","MISSING")
If you need more elaboration, I'd be happy to help, just reply to this. There might be an easier way, but I personally liked the straight-forwardness of this. You only need Microsoft excel!
EDIT:
For me, I used these two videos which go over the power query and countif function:
How to Get the List of File Names in a Folder in Excel (without VBA): https://www.youtube.com/watch?v=OSCPVBWOqwc
How to Compare Two Excel Sheets (and find the differences): https://www.youtube.com/watch?v=8Ou_wfzcKKk
In my case, I made my sheet look like this:

Programmatically set default column values based on folder in SharePoint Online

I'm working on enhancing metadata in our SharePoint online (O365) environment. Since a portion of my user base is used to foldering (explorer style), I've started using default column values to automatically set values on any files added to that specific folder (we have content organized categorically by folder currently). An example is our HR documents library - we have separate folders for recruiting, payroll, personnel files, etc. that automatically categorize files added to that folder with the same categories (recruiting, payroll, personnel, etc.). This supports both "search" and "click" users and makes adoption WAY easier while getting important metadata.
I want to implement this in a larger, more dynamic fashion, so manually setting default column values on each folder is not going to be scalable.
How can I reference the top level folder within the library (or even the current folder) for each newly added file and populate the "category" field for that new file with that folder name? I can do some very basic C# or Java code copy/paste, but bonus points for non-coding solutions =)
This problem can be solved through no coding.You can use the workflow to implement this by SharePoint Designer.
Create different view for different function team, and then use the view filter to show the document.
If you upload a file, use the workflow to set the metadata of the file. There are some known limitations: if you upload multiple files at the same time, the metadata for the file maybe does not work well; or if you upload a folder, the meta will not work for it and the file in the folder may not be set to right metadata.
I was actually able to use MS Flow to accomplish this in a pretty simple and straightforward fashion without managing custom views per team. The concept at a high level was:
(Trigger) When a new document is created in a folder in the library
Get the link of the parent folder of the newly added document
Create a variable (or just code it out in the Flow step) to parse out the name of the parent folder from the parent folder link (should be all text to the right of the last "/")
Set the category field as the variable
I'm sure that you could do the same right in a SharePoint designer workflow, but I prefer flow due to the visual aspect of it and being far easier to troubleshoot.

Common place for custom helper Matlab scripts and function?

Matlab Central file exchange contains numerous helper scripts and functions. Is it possible to place them somewhere in order not to populate current (project) directory with helper files?
There is set of functionality that concerns itself with search path (documentation).
What Is the MATLAB Search Path?
The search path, or path is a subset of all the folders in the file system. MATLAB® software uses the search path to efficiently locate files used with MathWorks® products. MATLAB can access all files in the folders on the search path.
Add Folders to Search Path Upon Startup
The startup.m file is for specifying startup options. You can add folders to the search path by including addpath statements in startup.m. For example, to add the specified folders, /home/username/mytools to the search path, include this statement:
addpath /home/username/mytools

Google Drive - Accessing file tree entries and their type

How does one retrieve the file tree for a google drive account using the Google Drive iOS API?
I am able to access the list of files from what I have read on the developer site for Google Drive and through the sample apps, but I am not sure how one gets the file tree and how to distinguish if an entry is a folder or file.
You can check the mimeType property of the file resource to distinguish between files and folders. Folders will list application/vnd.google-apps.folder as their MIME type:
https://developers.google.com/drive/folder
You can use the Parents collection to list the parents of a file and build a tree. Remember that a file can have multiple parents, i.e. be included in multiple folders:
https://developers.google.com/drive/v2/reference/parents/list