Check Excel file format from PowerScript not relying on file extension

0 votes

We have a number of Excel files that are stored in .xlsx or .xlsm format. Unfortunately the last letter of the file extension got dropped in another IT system so that they all have the file extension .xls. But we also have Excel files stored in .xls format.

I would need to write a PowerShell script to detect the actual Excel file format and then rename the files so that they file extension fits to the content. We have thousands of these files so it is not an option to it manually.

I found information on how to differentiate between .xls and the newer XML formats like .xlsx and .xlsm (by inspecting the first characters in the file). But I have not yet been able to find any information on how to determine if it is an .xlsx or .xlsm.

Any ideas?

Mar 31, 2022 in Database by Edureka
• 13,670 points
319 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

Merge excel files into a new excel file based on filename

How do I merge Excel files that ...READ MORE

answered Mar 31, 2022 in Database by gaurav
• 23,260 points
1,835 views
0 votes
1 answer

how to change format of date from mm/dd/yyyy to dd-mmm-yyyy in MS Excel

First, pick the cells that contain dates, ...READ MORE

answered Apr 11, 2022 in Database by gaurav
• 23,260 points
151,905 views
+2 votes
1 answer

How to export data from MySql to a CSV file?

If you are using MySql workbench then ...READ MORE

answered Jan 4, 2019 in Database by Priyaj
• 58,090 points
1,186 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to sort dates from Oldest to Newest in Excel?

Drag down the column to select the ...READ MORE

answered Feb 23, 2022 in Database by gaurav
• 23,260 points
4,574 views
0 votes
0 answers

How to import JSON file to Excel without coding?

Let's say you have a file named input.json which ...READ MORE

Feb 24, 2022 in Database by Edureka
• 13,670 points
498 views
0 votes
1 answer
0 votes
1 answer

Remove special characters from the specified string in excel

To erase a specific character from a ...READ MORE

answered Mar 15, 2022 in Database by gaurav
• 23,260 points
1,228 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP