Computing.Net > Forums > Programming > Help with Script to process files

Help with Script to process files

Reply to Message Icon

Original Message
Name: cranky_pants
Date: January 9, 2007 at 08:01:22 Pacific
Subject: Help with Script to process files
OS: Win2k3
CPU/Ram: intel 2gig
Model/Manufacturer: dell
Comment:

Hello,

I'm looking for some help with creating a script (of any flavor) that will accomplish the following:

I have a vendor supplied executable that processes text files based on the name of the text file. The text filename is an argument that can be given to the executable. When this is run, it creates a log file and reject file. This is great if I have one text file that needs to be processed now and then, but I will have several of these txt files generated every hour. I need the ability to envoke the executable to process new txt files that will have a time stamp (making them unique), and save the log\reject for each txt file processed.

I can't tell the executable to simply process *.txt...it does not like that.

Any and all help would be greatly appreciated!!



Report Offensive Message For Removal

Response Number 1
Name: StreamLogic
Date: January 11, 2007 at 08:23:39 Pacific
Subject: Help with Script to process files
Reply: (edit)

cranky_pants,

I personally would use VBScript on a Windows platform. Without writing the entire script, here are the steps I'd take:

1) Create a .vbs file using notepad
2) Use the FileSystemObject to open a folder, and "look" for files within that folder
3) When file(s) are found, process them with the executable by calling a Shell.Run on the executable.
4) Once this .vbs is written, schedule it with Windows Scheduler (scheduled tasks).

Hope this helps,
Curtis


Curtis Hughes
StreamLogic Inc.
http://www.streamlogicinc.com


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: January 11, 2007 at 08:35:24 Pacific
Subject: Help with Script to process files
Reply: (edit)

If it's simply a matter of getting the exe to act on each txt file:

::== mp.bat
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%A in ('dir /b *.txt') do (
myprog %%A
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: January 11, 2007 at 16:01:38 Pacific
Subject: Help with Script to process files
Reply: (edit)

If you need to track which have been done and not do any one twice, try this:

::== m3.bat
@echo off >> done.log
setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%A in ('dir /b *.txt') do (
find "%%A" < done.log > nul
if errorlevel 1 call :sub1 %%A
)
goto :eof

:sub1
echo %* >> done.log
echo prog %*
goto :eof


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Help with Script to process files

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software