That's what I'm thinking too ---- I just tried this with AI and ChatGPT provided this -
@echo off
REM Set the folder paths
set source_folder=C:\INCOMING\ORDERS
set archive_folder=C:\ARCHIVE
set output_file=%source_folder%\ORDERS.CSV
REM Check if the source folder is empty (excluding ORDERS.CSV)
dir /b /a-d "%source_folder%" | findstr /v /i "ORDERS.CSV" >nul
if %errorlevel% neq 0 (
echo No files to concatenate. Exiting...
exit /b
)
REM Delete the existing ORDERS.CSV if it exists (optional)
if exist "%output_file%" del "%output_file%"
REM Concatenate all files except ORDERS.CSV into ORDERS.CSV
(for %%f in ("%source_folder%\*.*") do (
if /i not "%%~nxf"=="ORDERS.CSV" type "%%f"
)) > "%output_file%"
REM Check if concatenation was successful
if errorlevel 1 (
echo Error during file concatenation. Exiting...
exit /b
)
REM Move the original files (excluding ORDERS.CSV) to the archive folder
for %%f in ("%source_folder%\*.*") do (
if /i not "%%~nxf"=="ORDERS.CSV" move "%%f" "%archive_folder%\"
)
REM Check if the move was successful
if errorlevel 1 (
echo Error moving files to archive. Exiting...
exit /b
)
echo Files successfully concatenated and moved to archive.
REM End script
exit /b
------------------------------
Wayne Schulz
wayne@s-consult.comSchulz Consulting
(860) 516-8990
Moodus, CT
------------------------------
Original Message:
Sent: 10-01-2024 16:33
From: Kevin Moyes
Subject: Automate a VI import to Sales Order to read and import any files in a folder
I've done this with a VBScript. Basically, loop through the CSV files in the folder, consolidate them into an AllOrders.CSV file, move / rename the consolidated files as their contents are being copied into the import file (avoiding re-processing in the future), then run the VI job (against the AllOrders.CSV file).
------------------------------
Kevin Moyes
Technical Systems Analyst
Munjal White Consulting Co.
Toronto ON
------------------------------