Automated Document Conversion using Task Scheduler


The following sample uses a batch file and the Windows® Task Scheduler to set up a drop folder that will use File Conversion Center to automatically convert any documents copied into the folder to faxable TIFF images. Once the documents are converted, they and the original source files are then moved to a subfolder named using the current date and time.This sample requires File Conversion Center 6.0 Professional Edition. It uses command line options for running in silent mode that are only available in the Professional Edition.The sample is divided into two sections:
  1. The first section covers how to download the required sample files, extract them and run the batch file manually.
  2. The second section also details the steps needed to add an automated task in Task Scheduler that uses the batch file to monitor a drop folder in 10 minute intervals and convert any file copied into the folder.
Running the Batch File Manually Setting up a Drop Folder with Task Scheduler Command Line Syntax Reference

Running the Batch File Manually

This section extracts the zip file contents, copies the source documents to the appropriate folder and and manually runs the batch file.
Required Download: autoconvert.zip
The zip file contains the batch file, pre-created folders and sample documents used in the steps below. Click the link above to download the file.
  1. File Conversion Center 6.0 Professional Edition must be installed and licensed on the computer. This batch file will not work with the Standard Edition or with the product in trial mode.
  2. If you are converting Microsoft Office documents, such as Word or Excel files, Microsoft® Office XP, 2003, 2007, 2010 or 2013 needs to be installed. If you are converting Adobe® PDF documents, either Adobe® Reader, Adobe® Acrobat or GhostScript need to be installed.
  3. Download the autoconvert.zip file to your Documents folder. This will be called My Documents if you are running Windows® XP, and Documents if you are running Windows® 10, Windows® 8, Windows® 7 or Windows Vista™.
  4. Extract the contents of the zip file by right-clicking on autoconvert.zip and selecting Extract All… from the context menu.
  5. Select a folder to copy the files into and leave Show extracted files when complete checked. Press the Extract button in the lower right to start.
  6. A window will appear showing the new folder, here named autoconvert, with the extracted contents of the zip file. The zip file contains a batch file named autoconvert.bat and three folders, INPUT, OUTPUT, and Sample Files. The Sample Files folder contains 4 sample documents to use when testing.
  7. To test the batch file, copy the files from the Sample Files folder into the INPUT folder, or if desired, use your own files. File Conversion Center can convert the following file formats:
    • Microsoft Word files (*.doc, *.docx, *.rtf, *.txt, *.wri, *.log)
    • Microsoft Excel files (*.xls, *.xlsx, *.xlw, *.xlc)
    • Microsoft PowerPoint files (*.ppt, *.pptx, *.pps)
    • HTML files (*.htm, *.html, *.shtm, *.shtml)
    • Adobe PDF files (*.pdf)
    • PostScript files (*.ps)
    • JPEG image files (*.jpg)
    • TIFF image files (*.tif)
    • Windows Bitmap image files (*.bmp)
    • ZSoft PCX and DCX image files (*.pcx, *.dcx)
    • CServe Portable Network Graphics (*.png)
    • Graphics Interchange Format (*.gif)
  8. Run the conversion by double-clicking on the batch file autoconvert.bat.
  9. A Command Prompt window will open and the batch file will launch. The batch file does the following at the beginning:
    1. finds the current directory
    2. adds File Conversion Center to the %PATH% environment variable
    3. checks for the required folders, INPUT and OUTPUT and exits if they do not exist
    4. checks for a folder named STAGING, if this folder exists, another instance of the batch file is already running and this one exits
    5. moves all files from the INPUT folder to the STAGING folder
    6. Launches File Conversion Center to convert the files. The batch file uses the DOSFCC6.exe executable here to cause the batch file to wait while the files are processed. This ensures that the batch file does not move ahead and process the new files until all files have been converted. A progress dialog appears while the conversion is running. This can be controlled using command line switches. The batch file contains a sample of how to run File Conversion Center without showing the progress dialog.
  10. When the conversion is complete the progress dialog will automatically close. When it does, control is returned to the batch file and the next commands after the call to File Conversion Center are run.It is at this point that any desired custom action can be taken on the files created. The batch file creates two new folders named using the current date and time, one for the converted files and one to store the original source files. Here you can see the two new folders, 10_03_2010_12_23_39 and 10_03_2010_12_23_39_source that were created when the batch file was run on March 10, 2010 at 12:23:39 pm. Your folder name will be based on the date and time of your run.
  11. The new files, the log file and a results file created by File Conversion Center are copied into the folder 10_03_2010_12_23_39.

Setting up a Drop Folder with Task Scheduler

This section shows you how to add a scheduled task to the Task Scheduler. The scheduled task will use the batch file autoconvert.bat and the folder structure extracted from the autoconvert.zip file to create the necessary folder structures for the task to run successfully.The scheduled task will monitor a drop folder (or watch folder) and to convert any documents dropped into the folder. The task has a delayed start of one minute after the user has logged in, and then runs again every 10 minutes thereafter.Required Download: autoconvert.zipThe zip file contains the batch file, pre-created folders and sample documents used in the steps below. Click the link above to download the file.
  1. Setting up scheduled tasks requires that you have Administrative privileges.
  2. File Conversion Center 6.0 Professional Edition must be installed and licensed on the computer. The batch file used by the scheduled task will not work with the Standard Edition or with the product in trial mode.
  3. If you are converting Microsoft Office documents, such as Word or Excel files, Microsoft® Office XP, 2003, 2007, 2010 or 2013 needs to be installed. If you are converting Adobe® PDF documents, either Adobe® Reader, Adobe® Acrobat or GhostScript need to be installed.
  4. Download the autoconvert.zip file to your Documents folder. This will be called My Documents if you are running Windows® XP, and Documents if you are running Windows® 10, Windows® 8, Windows® 7 or Windows Vista™.
  5. Extract the contents of the zip file by right-clicking on autoconvert.zip and selecting Extract All… from the context menu.
  6. Select a folder to copy the files into and leave Show extracted files when complete checked. Press the Extract button in the lower right to start.
  7. A window will appear showing the new folder, here named autoconvert, with the extracted contents of the zip file. The zip file contains a batch file named autoconvert.bat and three folders, INPUT, OUTPUT, and Sample Files. The Sample Files folder contains 4 sample documents to use when testing.
  8. Copy the files from the Sample Files folder into the INPUT folder created from the zip file. The INPUT folder will become the drop folder (or watch folder) when the scheduled task is running. By copying the files now, there will be documents to convert when the task is started.
  9. Open the Task Scheduler by typing “Task Scheduler” in the Search box on the Start menu then press the Enter key or click on the Task Scheduler program icon in the programs list. If you are running Windows® 10, Windows® 8 or Windows® 8.1, type “schedule tasks” into the search box. You may be asked to provide permissions to run the program.
  10. The Task Scheduler application will launch. Select Task Scheduler Library, then click on the Create Basic Task… link on the right hand side of the screen.
  11. The first step is to name your task and provide a description.
    1. Enter a name for your task in the Name: field.
    2. Enter a description for your task in the Description: field. This field is optional but is useful in remember what the task does without having to open the task properties.
    3. Click the Next button in the lower right to continue.
  12. The next step is to set the task trigger. A trigger is the action that will start the task. The trigger can be time-based or event-based. A time-based trigger starts the task when a particular date and/or time has been reached. An event based task starts when the required system event occurs, such as user log on or computer start-up.In this sample the trigger is the user logging into the computer. The trigger will later be enhanced with a delay before starting and to set up a 10 minute interval so that the task will run every 10 minutes.
    1. Choose to start the task When I log on.
    2. The trigger will be modified in a later step to add in the delay and to configure the the task to repeat every 10 minutes.
    3. Click the Next button in the lower right to continue.
  13. This step sets the action to take when the trigger starts the task. For this sample, running the autoconvert.bat batch file, which is a program, is the desired action.
    1. Select Start a program as the action. The next screen will allow you to select the program to run.
    2. Click the Next button in the lower right to continue.
  14. From here, select the program to run. Optional fields include any arguments to be passed to the program and the directory from which to start the program.
    1. Set the Program/Script to run by using the Browse button to find the folder where autoconvert.bat is located and select that file as the program to run.
    2. There are no arguments for the batch file.
    3. The Start in: field must be set to the same directory as the autoconvert.bat, which is the following in this case: C:\Users\FCCUser\Documents\autoconvert\. Your path may be different.
    4. Click the Next button in the lower right to continue.
  15. The last screen is a summary of the Task settings. To set more advanced settings the Properties dialog can be displayed after the task has been created.
    1. Enable the Open the Properties dialog for this task when I click Finish to set advanced options on this task.
    2. Click the Finish button in the lower right to save and add the task.
  16. The task’s Properties dialog will be displayed next; on the dialog is a set of tabs for modifying the more advanced settings.a) On the General tab, enable the Run with highest privileges option. This option is required to be enabled if the user running the task has administrative privileges.b) On the Triggers tab, select the trigger and then click the Edit… button to modify the trigger. The trigger needs to be changed to add the 1 minute delay on first run and the 10 minute interval between runs.c) On the Edit Trigger dialog, set the following:
    • i) Enable Delay task for and set the delay to 1 minute.
    • ii) Enable Repeat task every and set the interval to 10 minutes
    • iii) Set the for a duration of: to Indefinitely.
    • iv) Click OK to save the changes to the trigger and return to the Properties dialog.
  17. Back on the Properties dialog, click the OK button to save the changes to the task’s settings.
  18. The updated task will be listed in the Task Scheduler Library with a brief description of the task triggers.
  19. To start the task, log off the computer and log back in; this is because the task’s trigger is set to When I log on.
  20. After logging on, and the 1 minute delay, the task will start to run. After the first run, the Task Scheduler will run the batch file every 10 minutes.Each time the batch file starts, the following is done:
    1. finds the current directory
    2. adds File Conversion Center to the %PATH% environment variable
    3. checks for the required folders, INPUT and OUTPUT and exits if they do not exist
    4. checks for a folder named STAGING, if this folder exists, another instance of the batch file is already running and this one exits. This can happen if a previous instance of the task is running with a very large amount of files and it is taking longer than 10 minutes to process all files.
    5. moves all files from the INPUT folder to the STAGING folder
    6. Launches File Conversion Center to convert the files.
    The batch file uses the DOSFCC6.exe executable here to cause the batch file to wait while the files are processed. This ensures that the batch file does not move ahead and process the new files until all files have been converted.A progress dialog appears while the conversion is running. This can be controlled using command line switches. The batch file contains a commented sample line of how to run File Conversion Center without showing the progress dialog.
  21. When the conversion is complete the progress dialog will automatically close. When it does, control is returned to the batch file and the next commands after the call to File Conversion Center are run.It is at this point that any desired custom action can be taken on the files created. The batch file creates two new folders named using the current date and time, one for the converted files and one to store the original source files.Here you can see the two new folders, 10_03_2010_15_24_38 and 10_03_2010_15_24_38_source that were created when the batch file was first run on March 10, 2010 at 15:24:38 pm, and the next two folders, 10_03_2010_15_34_35 and 10_03_2010_15_34_35_source that were created when the batch file was run 10 minutes later on March 10, 2010 at 15:34:35 pm. Your folder names will be based on the date and time of your run and will be different from those shown here.

File Conversion Center Professional Command Line Syntax Reference

PNFCC6.EXE [/Q] [/R] [/X] [/H] [/N] [/J=jobfile] [/P=profile] [/I=importfile][/O=outputdir] [/F=filterlist] [/S=0|1] [/M=0|1] [/L=logfile,a|o][item1 item2 . . .]

NOTE: Use DOSFCC6.exe instead of PNFCC6.exe when calling File Conversion Center from a batch or scripting file if you need to wait until the job is complete before returning control to the batch or script file.

SwitchDescription
/QRun a conversion job silently with no graphical interface. Professional Edition only.
/RRun a conversion job and display only the conversion progress dialog. The progress dialog will remain on the screen when conversion is done.
/XCan only be used with the /R option; automatically closes the progress dialog when the conversion process is complete. Professional Edition only.
/HDisplays the help dialog containing descriptions of the command line switches.
/NSuppresses all error message dialogs, errors are logged into the event viewer instead. Professional Edition only.
/J=jobfileLoad and run a saved job file.
/P=profileUse this profile when running the job. This switch will override any job file settings specified by the /J switch.
/I=import text fileLoad a text file containing a list of files, folders, and web addresses to be converted. This switch can be repeated as required. Information is added to any input specified by a job file or on the command line.
/O=output dirUse this directory to store the converted files. Overrides any settings supplied by the /J and /P switches.
/F=filter by extensionList the file types, by extension that will be included in the job when processing folders selected for conversion. The file extensions must be separated by commas with no spaces. Overrides any settings supplied by the /J and /P switches.
/S=0|1Use 1 to include any subfolders when converting folders of files, 0 to process only the files in the folder. Overrides any settings supplied by the /J and /P switches.
/M=0|1Set to 1 to maintain the directory structure when converting subfolders of folders, or 0 to put all new files in a single output folder. Overrides any settings supplied by the /J and/P switches.
/L=logfile, a|oCreate a log file of the conversion. Adding ,a to this switch allows you to append the information to an existing log file, while adding ,o allows you to overwrite an existing log file. The file extension for the created log file will always be .log.
item1 item 2 …Specify the files, folders, and web addresses to convert during the job.