Select text files according to their data

December 10, 2010 at 14:56:04
Specs: Windows XP
I am getting two set of files, but I only have to process one set as the other one is an ecrypted version of the first one; the originator (outside of my company) keeps switching them between two folders so I am downloading both set of files (in separate folders: invoices and temp).
What I need to do now, is to incorporate in my batch process how to identify which set is the text file. These files always start with "INVOICE NUMBER".
I could get some help to write a batch that identifies these files and moves them to the processing folder and does nothing with the encrypted files.
Gus -Gusbunny

See More: Select text files according to their data

Report •

December 10, 2010 at 17:40:57
Hi Gus - here's a script which will move the text files in both sets of files just in case your client starts mixing them. Leave you to amend paths\filenames to suit, do the testing, and to write the Move command line.

Good luck

@echo off
setLocal EnableDELAYedeXpansion

pushd %temp%\invoices\||echo Pushd failed - job terminated&&exit /b
call :moveit

pushd %temp%\temp\||echo Pushd failed - job terminated&&exit /b
call :moveit

for /f "tokens=*" %%1 in ('dir /b /a-d *.txt') do (
    set /p line1=<%%1
    if /i "!line1:~1,14!" equ "invoice number" echo moving %%1

Did you Google for an answer before asking the question?

Report •

January 11, 2011 at 12:19:02
Hey Wahine

Thanks a lot, I am not really familiar with assigning routes (pushd commands) but the bottom part I was able to understand it and apply it.
I have been running my scripts for a couple of weeks and it works like a charm.
Thanks a lot and Happy New Year!

Report •

Related Solutions

Ask Question