GEEK STUFF


HostMonster web hosting - 50 GB space 999 GB transfer Raw log files Counters CGI-BIN $4.95 per month

Unlimited Domains • Raw Stat Logs • Counters • CGI-BIN • $4.95 mo.
SIGN UP FOR HostMonster.COM NOW


4NT Code Samples - Page 5

CREATE CHECK NUMBER HARD LINK FOR IMAGES OF CHECKS

This requires an NTFS file system found on Windows 2000 and Windows XP.
This will not work on Windows 95, Windows 98 or Windows ME.
This will not work on Windows 2000 or Windows XP if the hard disk is set up with FAT32 instead of NTFS.
This requires 4NT from JP Software.

Explanation:

I download images of my checks from my bank and store them on my hard disk. I often use more than one check book, which means checks are issued out of sequence.

Here is the storage format I use:

C:\BANKING\2004\Checks\1400\
C:\BANKING\2004\Checks\1500\
C:\BANKING\2005\Checks\1500\
C:\BANKING\2005\Checks\1600\
The first subdirectory holds all checks written in 2004 in the range 1400 through 1499.
The second subdirectory holds all checks written in 2004 in the range 1500-1599.
The third subdirectory holds all checks written in 2005 in the range 1500-1599.

Image filenames have the format MM-DD-YY CHECKNUMBER.png
MM-DD-YY is the date shown on the check.

So, if Check 1561 was written November 22, 2004 it would be saved as:
C:\BANKING\2004\Checks\1500\11-22-04 1561.png

If Check 1591 was written January 12, 2005 it would be saved as:
C:\BANKING\2005\Checks\1500\01-12-05 1591.png

The problem is that I have a chronological listing but not a listing by Check Number. This utility creates a hard link listed by Check Number.

About Hard Links:

Files are stored in a physical location on a computer disk. Elsewhere on the disk is a directory. The directory contains a name used to reference the physical file and the address of the actual file on the disk. In an NTFS file system, technically, that reference is a "hard link".

Every file must have one hard link.

But NTFS allows more than one hard link to the same file. Windows 98 and Windows ME allow a shortcut that points to a file. These are soft links. If the file is deleted, the soft link will still exist and will now point to nothing. In addition to soft links, Windows 2000 and XP also allow hard links. A hard link is a second directory entry for the same file. If a file has several hard links, the file is not deleted until all hard links are deleted.

In practice, how do you use this utility?

If you store check number images in the format ##-##-##<space>####.png you can simply go to that directory in 4NT and type CHECKNUMS and it will create a set of hard links in the format CHECKNUMBER.ckn.

If you store checks in the format YY-MM-DD it won't matter. This utility simply looks for a certain pattern. If your pattern is different, just change those sections below.

Example:

1) You have downloaded four check images to the same directory:

11-22-04 1560.png
11-24-04 1561.png
11-24-04 1562.png
11-26-04 1565.png   (Note that checks 1563 & 1564 are missing)

2) You go to that directory and type CHECKNUMS

3) New directory entries (hard links) will be created with these names:

1560.ckn
1561.ckn
1562.clm
1565.ckn

Note: It will appear that file 11-22-04 1560.png has been copied to file 1560.ckn. You will see full directory entries with a date, time, file size, etc. On the file icon you will not see the little arrow indicating a shortcut (.lnk) file. However, the .ckn entries are neither independent files (copies) nor shortcuts. They exist only as directory entries, not as separate files on the disk. What you have done is give a single file two separate file names--two separate directory entries.

So, if you want to see the checks chronologically, look at the .png entries. If you want to see them in check-number order, look at the .ckn entries.

Note: Because the file now has two directory entries, deleting only one does not actually delete the file.


This requires 4NT from JP Software.

:   by Joseph "Rick" Reinckens
:   Please visit www.GodOnThe.Net
:
:   This requires 4NT from www.JPSoft.com
: Creates a hard link with the check number
: for each check image file. Name must be in format MM-DD-YY<space>####.png 

@echo off

: Delete existing .ckn files
del /q *.ckn

: Create a file list
dir /b "??-??-?? ????.png">checks.lst

: Just as a precaution
  UNFUNCTION Check_*

  FUNCTION Check_Date=`%@instr[1, 8, %1]`

  FUNCTION Check_Num=`%@instr[1, 4, %2]`

: Create a hard link to each check file
for %checknum in (@checks.lst) (

    set cknum=%@check_num[%checknum]
    set ckdate=%@check_date[%checknum]

    mklnk "%checknum" %cknum.ckn
)

dir *.ckn

del checks.lst
UNFUNCTION Check_*
                


GOD ON THE NET

(c) 2006 Rick Reinckens