This project provides a simple batch script (Filters.bat) that processes an Excel file to calculate the total quantities of filters by size and outputs the results to a CSV file. It’s designed for users who need to tally filter orders from a spreadsheet without manual effort.
The script reads an Excel file in the same directory, where:
- Column B (starting at B2) lists filter sizes (e.g., "20x20x1").
- Column C (starting at C2) lists quantities.
It groups identical sizes, sums their quantities, and saves the totals to
filter_totals.csv.
- Windows: The script runs on Windows via Command Prompt.
- PowerShell: Included with Windows, used to execute the script.
- Excel File: An
.xlsxfile with filter data (no headers required). - Internet (first run): To install the
ImportExcelPowerShell module if not already present (requires admin rights).
-
Prepare Your Excel File:
-
Place your filter data in an
.xlsxfile (e.g.,filters.xlsx). -
Ensure sizes are in Column B (B2 onward) and quantities in Column C (C2 onward).
-
Example:
B C 20x20x1 5 12x12x1 1 20x20x1 5 12x12x1 1 -
Save it in the same folder as
Filters.bat(e.g.,c:\Tools\tests).
-
-
Run the Script:
- Open Command Prompt.
- Navigate to the script’s folder:
cd c:\Tools\tests. - Execute:
Filters.bat. - The script finds the first
.xlsxfile in the directory and processes it.
-
Check the Output:
-
Results are saved to
filter_totals.csvin the same folder. -
Example output (
filter_totals.csv):"Size","TotalQuantity" "20x20x1","10" "12x12x1","2" -
Open it in Excel or a text editor to review.
-
- File:
Filters.bat - Process:
- Checks for and installs the
ImportExcelmodule if needed. - Finds an
.xlsxfile in the current directory. - Reads data from "Sheet1", starting at B2 (sizes) and C2 (quantities).
- Groups sizes, sums quantities, and exports to
filter_totals.csv.
- Checks for and installs the
- Cleanup: Deletes the temporary PowerShell script (
temp_script.ps1) after running.
- Sheet Name: Edit
-WorksheetName "Sheet1"in the script if your data is on a different sheet (e.g.,-WorksheetName "Filters"). - Output File: Change
"filter_totals.csv"to another name if desired (e.g.,"results.csv"). - File Location: The script assumes the
.xlsxfile is in the same directory. Move it and adjust paths if needed.
- No
.xlsxFile: If no Excel file is found, the script exits with a message. - Admin Rights: First run may require admin privileges to install
ImportExcel. - Errors: If you see "
) was unexpected", check for syntax issues or share the output for help.
This is a simple utility script with no formal license—use it freely for your filter-ordering needs!
For issues or suggestions, feel free to reach out (or imagine you’re asking an AI assistant who helped build this!)