#! /bin/perl ############################################################################# # # NOTE: This file under revision control using RCS # Any changes made without RCS will be lost # # $Source: U:\\mhansen\\bin\\RCS\\4tnox2splash.pl,v $ # $Revision: 1.0 $ # $Date: 2003-04-05 23:42:20-06 $ # $Author: mhansen $ # $Locker: mhansen $ # $State: Exp $ # # Purpose: Utility to convert 4TNox exported records to CSV file # to import to SplashID. # # Directions: Usage: 4tnox2splash.pl [directory] # directory is optional argument, directory to start # in. Current directory is default. # # From 4TNox export each category sequentially. # - Choose each category separately. # - Choose "export to memopad" from the "options" menu. # - 4TNox will place each exported category into a # separate "unfiled" memo file titled "4TNox Export." # # From the memo pad application # - Rename each memo to the category name. # - Check to see that entire category was exported to # each memo. Categories past a certain length are # truncated. If category is truncated, divide into # smaller categories and export again. # # HotSync Palm with Palm desktop # # From the Palm Desktop # - Choose each memo created in the steps above # sequentially. # - Choose "Export" from the "file" menu # - Set export type to "text" and choose any unique file # name ending in .txt. Put all exported files in a # directory that contains no other .txt files. # - On the "Specify Export Fields" dialog box, uncheck # everything except "memo" and pick "OK" # # From a command console run the perl program # "4tnox2splash.pl." Either change to the directory with # the exported 4tnox files to run the command or supply # the full path to the directory as an argument to the # program. # # Expects all *.txt in directory to be input files. # # Outputs a single file "splash.csv" in same directory # as input files. # # Double quotes would interfere with the CSV file format # so all double quotes in input files are translated to # single quotes. # # Choose "Import CSV" from the file menu in the desktop # SplashID application. Import splash.csv file. # # 4TNox Field SplashID Field # ----------- -------------- # Description Custom1 # Type Not copied # User Name Custom2 # Password Custom3 # Date Not copied # Notes Notes # # All other 4TNox fields/values are added to SplashID # notes field, showing both field and value names. # # Default Location: U:\mhansen\bin # # Invoked by: user # # Copyright (C) 2003 Marc Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation available at: # http://http://www.gnu.org/copyleft/gpl.html # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # ############################################################################# # # # REVISION HISTORY: # # $Log: 4tnox2splash.pl,v $ # Revision 1.0 2003-04-05 23:42:20-06 mhansen # Initial revision # # # # # Get starting directory # $dir = "@ARGV[0]"; if (! $dir) {$dir = "."} # # Main # print "\nFinding files in $dir\n\n"; # Build list of *.txt files in specified directory opendir(DIR, $dir); while (defined($file = readdir(DIR))) { if (-f "$dir/$file" && "$file" =~ /\.txt$/ ) { push @filelist, "$dir/$file"; } } closedir (DIR); # Open output file open OUT, ">$dir/splash.csv"; # Loop for each input file in directory foreach $file (@filelist) { # Open file open TXT, "<$file"; $top=0; # First line is export memo name, use for catagory name $catg=; chomp $catg; $catg =~ s/\r*$//; # 4Tnox files soemtimes have xtra CR's print "Processing $file, Catagory: $catg\n"; # Loop for remaining lines in file while () { chomp $_; $_ =~ s/\r*$//; # 4TNox files sometimes have xtra CR's $_ =~ tr/\042/\047/; # Change " to ' if (/4TNox/ && $top) { &recout; next; } if (/4TNox/) {$top++; next;} if (/^Desc:(.*$)/) {$c1=$1} elsif (/^User:(.*$)/) {$c2=$1} elsif (/^Pass:(.*$)/) {$c3=$1} elsif (/^Date:/) {next;} elsif (/^Type:/) {next;} else { $_ =~ s/^Notes://; push @notes, $_,"\n"; } } &recout; close TXT; } close OUT; print "\n$cnt records processed.\n"; ################### # # Function: recout # Purpose: output one record # sub recout { $cnt++; print OUT '"',"$catg",'"'; print OUT ',"',$c1,'"'; print OUT ',"',$c2,'"'; print OUT ',"',$c3,'"'; print OUT ',""'; print OUT ',""'; print OUT ',""'; print OUT ',"',@notes,'"',"\n"; undef (@notes); $c1=""; $c2=""; $c3=""; } __END__