Page 1 of 1

Sorting mechanism for scanned documents into folders

Posted: 18 Nov 2008 03:08
by casefolder
Hello,

I'm searching for a good solution of archiving scanned documents.

The problem:

Recently we bought a new copy-machine from toshiba. It includes the feature of scanning a bunch of documents on its own harddisk.

To keep up a structure (Law-firm) we give the files structured names:

{casenumber}{client}{typeofdoc}{dateofdoc}.pdf

So, by now we created a structured list of files in the scan-folder of the machine.

The next step is to move the files into subfolders on a different pc. These subfolders have 6 digits, simply the case numbers.

It should be very easy for a program to move these files paying attention to the case number and sorting them into the right case folders!

I have a code already working on my desktop test environment. The only thing is I need a line marking the file "read only" afterwards and creating an extension like "_1, _2, _3" if the filename in the destination folder exists already.

Code: Select all

@Echo Off
Setlocal EnableDelayedExpansion
Set _Source=C:\Documents and Settings\architect\Desktop\HarddiskToshiba
Set _Destination=C:\Documents and Settings\architect\Desktop\ZygosCases
For /F "tokens=*" %%I in ('dir "%_Source%\*.pdf" /b /a-d') Do (
    Set _fn=%%I
    Set _casenumber=!_fn:~0,6!
    If NOT EXIST "%_Destination%\!_casenumber!" MD "%_Destination%\!_casenumber!"
    Xcopy /CH "%_Source%\%%I" "%_Destination%\!_casenumber!"
)