public static void main(String[] args) throws InterruptedException, IOException {
		new File(output_dir, "").mkdirs();
		download_dir.mkdirs();
		
		FirefoxProfile profile = Utils.createFireFoxProfile();
		profile.setPreference("browser.download.dir", download_dir.getPath());

		WebDriver driver = new FirefoxDriver(profile);
		
		Utils.openTvdb(driver, "򥻪U");
		
        driver.findElement(By.partialLinkText("C L t ")).click();
        driver.findElement(By.partialLinkText("򥻸Ʈw")).click();
        
        (new WebDriverWait(driver, 30)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("table")));
        downloadTables(driver, "򥻸ƪ", EnumSet.allOf(OutputType.class));
        
        SortedMap<String, List<String>> tableUnits = new TreeMap<String, List<String>>();
        Set<String> unitSet = new HashSet<String>();
        
        Utils.obtainTableUnitMapping(tableUnits, unitSet);
        
        for(String unit: unitSet) {
    		new File(output_dir, "/"+unit+"/U").mkdirs();
    		new File(output_dir, "/"+unit+"/LƪU").mkdirs();
        }
        
        // Copy table files to the unit in charge according to the table-unit mapping
        for(String tableName: tableUnits.keySet()) {
        	if(tableUnits.get(tableName).isEmpty()) {
        		System.err.println("["+tableName+"]: no unit in charge");
        		continue;
        	}
        	
        	for(OutputType type: EnumSet.allOf(OutputType.class)) {
            	File tableFile = new File(output_dir, "򥻸ƪ/"+type.name+"/"+tableName+type.ext);
            	boolean tableFileExists = tableFile.exists();
            	if(!tableFileExists) {
        			File noData = new File(output_dir, "򥻸ƪ/"+tableName+"-L.txt");
        			if(!noData.exists()) {
	            		try {
            				noData.createNewFile();
            			}
	            		catch(IOException e) {
							System.err.println("Error creating no-data file for ["+tableName+"]");
	            		}
            		}
            	}
            	
            	for(String unit: tableUnits.get(tableName)) {
            		File unitDir = new File(output_dir, "/"+unit);
            		
            		// handle no-data tables
                	if(!tableFileExists) {
						File noData = new File(unitDir, "LƪU/"+tableName+".txt");
	            		System.out.println("["+tableName+"-L] => ["+unit+"]");
	            		
						if(!noData.exists()) {
							try {
    							noData.createNewFile();
	    					} catch (IOException e) {
	    						System.err.println("No-data: Error creating file for ["+tableName+"] ("+unit+")");
	    					}
						}
                		continue;
                	}
                	
                	// Copy basic data tables
            		try {
            			File targetFile = new File(unitDir, "U/"+tableFile.getName());
            			
            			if(!targetFile.exists()) {
        					FileUtils.copyFile(tableFile, targetFile);
            			}
    					System.out.println("["+tableFile.getName()+"] => ["+unit+"]");
    				} catch (IOException e) {
    					System.err.println("Error: ["+tableFile.getName()+"] => ["+unit+"]");
    				}
            	}
        	}
        }
     
        ((JavascriptExecutor)driver).executeScript("alert('Done!')");
	}