/* * Concordance Programming Language * Utility to bulk convert all databases from all subdirectories. * Copyright (C) 2000, 2004 Dataflight Software, Inc. ALL RIGHTS RESERVED. * Dataflight Software and Concordance are registered trademarks of Dataflight Software, Inc. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * */ /* Add your user name and password if the databases are password protected. */ text szUser = ""; text szPassword = ""; main() { char string[256]; int db, i, j; text pszPath, pszMask; if (ver() < 7.10) return(messageBox("This program requires Concordance V8.00 or later." + newline() + "You are using V"+str(ver(), 4,2,0)+". It cannot continue.", "Concordance Bulk Conversion Utility", 0)); i = messageBox("This program will bulk convert databases to Concordance V"+str(ver(),4,2,0)+"."+newline()+ "It will automatically convert every database in all subdirectories from the directory you specify." +newline() + newline() + "Would you like to do this now?", "Concordance Bulk Conversion Utility", MB_ICONQUESTION | MB_YESNO); if (i <> IDYES) return; i = messageBox("Have you made backup copies of all databases you wish to convert?", "Concordance Bulk Conversion Utility", MB_ICONQUESTION | MB_YESNO); if (i <> IDYES) { messageBox("Please make backup copies first. Then run this utility again.", "Concordance Bulk Conversion Utility", MB_ICONSTOP | MB_OK); return; } messageBox("Instructions: Choose a subdirectory and enter *.dcb for the file name.", "Concordance Bulk Conversion Utility", MB_ICONINFORMATION | MB_OK); /* Close any open databases. We can't convert */ /* them if we have them open with another handle. */ for(i = 0; i < 16; i = i + 1) closedb(i); /* Prompt the user for a database or a directory. */ if (getfile("DCB files", "*.DCB", string, OFN_NOVALIDATE) == CR) { /* If the user specified a single file, then load it. */ if (exist(string)) { if ((db = opendb(string, szUser, szPassword)) <> EOF) { convert(db); closedb(db); } } else { /* The file does not exist. Assume that the path has a */ /* wild card in it. Find the wild card and separate */ /* the path from the wild card specification. */ for(i = 0; string[i]; i = i + 1) if (string[i] == '\') j = i; pszPath = substr(string, 1, j + 1); pszMask = substr(string, j + 2); /* Confirm that the user wants to import the files, then call importPDF() to process the files and subdirectories. */ if (messageBox("Convert to V"+str(ver(),4,2,0)+" all databases from "+pszPath+" and all subdirectories?", program(), MB_YESNO) == IDYES) ConvertDatabases(db, pszPath, pszMask); } } } /* main() */ ConvertDatabases(int db; text pszPath; text pszMask) { char szFile[256]; text szPath; int i, length, db; /* First import all of the PDF files in the current directory. */ chdir(pszPath); for(szFile = findfirst(pszPath+pszMask, 0); szFile[0]; szFile = findnext()) { Message("Converting "+pszPath + szFile, FALSE); if ((db = opendb(pszPath + szFile, szUser, szPassword)) <> EOF) { convert(db); closedb(db); } } /* Now process all subdirectories. */ for(szFile = findfirst(pszPath+"*.*", 16); szFile[0]; szFile = findnext()) { /* Build a list of every path except . and .. */ if ((szFile <> ".") and (szFile <> "..")) szPath = trim(szPath + newline() + szFile); } /* Now call ourselves recursively to process each subdirectory. */ if (len(szPath) > 0) for(i = findline(szPath, 1, length); i <> 0; i = findnline(szPath, i, length)) { ConvertDatabases(db, pszPath+substr(szPath, i, length)+"\", pszMask); } } /* ConvertDatabases() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key; cursoroff(); if (wait) screen = save(5,13,8,96); box(5,13,7,96, "3D", RGB(160, 160, 160), RGB(190, 190, 190)); puts(6,14,pad(message,'C',80), RGB(0,0,0), RGB(190, 190, 190)); if (wait) { key = getkey(); restore(5,13,screen); } return(asc(upper(chr(key)))); } /* Message() */