Powershell - Delete specific word from a text file - powershell

I tried to search on google but I did not find anything about it,
Simply I have a .CSV file that contains for example this,
APPNAME,Status OK,Ping OK
APPNAME2,Status OK,Ping FAIL
There are multiple lines, all i need is to delete "Status" and "PING" from the text file so that the output will be like this
APPNAME, OK, OK
APPNAME2, OK, FAIL
Is that possible ? If so thank you for your reply.

Related

In Resilio Sync, how to add multiple keys at once

With Resilio Sync, I'm looking for a way to add multiple keys at once with a CSV file or run a script or copy-paste to a config file or whatever else.
Currently, I have a list of 10 keys I must set up on a laptop.
For each I have to click the '+' then 'Enter a key then copy paste the path to the folder I created for it.
I would prefer to have a list like this I could just load or parse with a script.
KEY,Folder Path,Selective sync
I6HK76FRZS...,C:\Sync\Folder1,No
76FRI6HKZS...,C:\Sync\Folder2,No
HK76FI6RZS...,C:\Sync\Folder3,No
.....
This would help reduce errors in copying and pasting information.
I've tried exploring the Internet and it looks like no one else has ever needed to do anything like this. :/ Hard to believe.
I've also tried researching the config file to see if I could add the information there.
https://help.resilio.com/hc/en-us/articles/206178884-Running-Sync-in-configuration-mode#windows
Storing the information permanently in raw text on a config file does not sound ideal.

Is it possible to extract metadata such as Content Created date from files - I can't get this with PowerShell

I need to extract the "Content Created" date out of thousands of files, but haven't been able to find a way to do this using PowerShell / other Command Line utility.
Does someone out there know a way to obtain this metadata? If so, please can you advise me. Thanks.
I've looked at various resources online, including this site, but haven't been successful thus far.
Here's a screenshot explaining what I'm trying to do.
I've been unable to find a native powershell cmdlet which does what you want. However, I found this article: Use PowerShell to Find Metadata from Photograph Files and the script it used: get file meta data function.
The article talks about image files, but the function is not specific for image files.
I tested it out on a folder containing a Word and an Excel file and the returned Metadata from the Word file contains the Content Created date. The Excel file does not contain/return that value. This is not unexpected as the Details tab of properties for the Excel file does not contain a Content Created value so it seems to be specific for Word files, and maybe some other file or document types.
Update:
You write that you need to extract this info from thousands of files, but if those files are anything but Word-files you probably won't be able to do that.
As far as I can tell this should work with the file types exposing the type of metadata you want. However, it seems that the ContentCreated property is unique to Word. I tried adding a text file (.txt), Acrobat PDF (.pdf), MS Access (.mdb), Excel (.xlxs) and a Word doc (.docx) file to my test folder and the only one that has/returns that metadata property is the Word file.
You should also be aware that the script seems to return metadata localized, so for me to programatically get the info i wanted I had to pipe the output of the script to Select-Object -Property Name,'InnehÄll skapat' (which is the Swedish name for Content created). So if you're running on a non-english system you may need to check what the output looks like before creating your Select-Object statement.
PowerQuery in Excel 2013 or later (data tab). Connect to data> Folder.

window command prompt for searching

When you use window and go to a folder, there will be a search box and when you write something there, windows will automatically search the folder and all subfolders inside it for the keyword (it searches the title and the content of all documents also).
I just wonder if there is a way to perform that similar action but in command prompt (I want to search all types of file: pdf, txt,...)
I have tried find and findstr but findstr only searches text file and for find it returns wrong result for me. Because I know for sure that for example the word 'dangerous' is in a document but the result from find is 0
Do you want it to search the filenames for the keyword or the actual contents of the file? In such case i think you will need to write a simple c++ program to stream the data of each file and search for the keyword that way

Command prompt for merging word documents

I have two word documents and I need to merge them into one word document using command prompt. Option copy *.extension newfile.extensions works with .txt or .csv file but if I do that with docx result of operation is corrupted word file.
You won't be able to achieve what you want (with command copy) as merging two word documents is a bit more subtle than just do a 'bit wise append' (which is what the copy command does).
Google give quite a few result when searching for 'merge word documents'. One of the result might point you to a tool that you can invoke at the command line.
Hope this helps.
I have need of something similar, and this was the best I could find: https://github.com/jamessantiago/DocxMerge
I haven't tried it yet, but from all I can tell there is no command line option for combining Word documents.
(Good to know: The .docx file is actually a zip file. Rename it to .zip and unzip it to view what's inside. Combining two documents is tricky, but obviously possible, from command line. But there is no built-in command to do it.)

Find corrupt data in xlsx file

We are generating xlsx files using a perl script. Files usually contains thousands of records. This makes spotting errors a very difficult operation.
This process was working since years without problems.
This week we got a request to check a file which contains errors. While opening Excel prompted that the file contains errors and asked whether we want to repair them.
In fact we do not want to recover the data but want to know which part of the file is corrupt. The error should be coming from corrupt data and we are interested to identify these data.
the log message shows the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error068200_01.xml</logFileName> </br>
<summary>Errors were detected in file 'D:\Temp\20161020\file_name.xlsx'</summary>
<repairedRecords summary="Following is a list of repairs:"><repairedRecord>Repaired Records: Cell information from /xl/worksheets/sheet1.xml part</repairedRecord>
</repairedRecords>
</recoveryLog>
The error should come from corrupt data. Is there any tool/method which helps to spot this corrupt data?
I tried renaming it a zip file, extracting it and opening it via an XML editor but was not able to find any errors in XML file.
We also checked that the different XML file structures are fine.
Thank you and best regards
As expected, the problem was coming from text cells containing numbers having an E in the middle.I used the following steps to identify the erronous cells.
1. Wrote small Java class to read the file. The class was checking the cell type and displaying the value afterwards.The java program generated an Exception at some line "Cannot get a numeric value from a text cell" even If I was correctly checking the cell type before displaying the content.
2. I checked the opened Excel file at that line and found that the cell contains only 'inf'.
3. I opened the file using open office and looked at the same cells. They contain 0.
4. I debugged the program generating the data and found out that these cells contain data like '914E5514'. Seems that E which was interpreted by Excel as an exponent.We changed the program to use the format '#' for that cell and this solved the issue.
Thank you.
Thank you very much, you helped me a lot by saying that 1 particular content item may be the root problem.
My corrupted content was https://www.example.com XYZ ... ASDAS
Solution: www.example.com XYZ ... ASDAS
This is something which cannot be handled by excel. Would be nice to have a list of thing which do not work