UPath More than unix like accessing files and folders for AutoHotkey

  1. What is UPath?
  2. Why UPath?
  3. Version Information
  4. Download
  5. Usage Examples

What is UPath?

UPath is an AutoHotkey script library for developers. It gets from an Unix like file address the Windows absolute path, but it do more than that. Relative addresses, wildcards ("*" and "?") and the "." and ".." will be extended also. The returned string will contain always the full path with drive letter. On default, system files and folders don't exist to UPath. The given path can start for example with a slash "/", which is the current drive letter from script. This makes the path portable. Also a regular expression filter can be specified, to filter out founded items. Only to the regular expression matched items would be returned. Read the included manual file for more information.

The source contain several functions named with @UPath, which indicates a private function to UPath and helping to prevent some conflicts with other sources. There are 2 public functions: UPath(), the main function with all its functionality and RunUPath(), which is not really a part of UPath.

UPath is not designed to be fast as possible, but readable and changeable in mind.

Why UPath?

May be you find it too trivial and not really useful. Yes, you may not need it, but on some situations, it could come handy to use UPath. It has some useful features and do more than a trivial string conversion. There are also some options. Here are some reasons why:

Version Information

Revision
0.4
Status
Experimental Beta
Date
Mon, 13 November 2006 07:33:38 GMT
Author
Tuncay tuncay.d@gmx.net
Homepage
http://www.autohotkey.net/~Tuncay/UPath/index.html
License
GNU GPL, Version 2
Type
Library
Standalone
Yes
Polymorph
No
Tested AutoHotkey Version
1.0.45.04
Tested Windows Version
XP Pro SP2

Changes from last revision

Warning!

UPath is currently under heavy development phase and not tested yet well. Use it only for testing. Future releases may not be compatible anymore. Also be careful with the option --subdirs.

Download

UPath Package, the archive contains a manual, the webpage, history file, testfiles and of course the source itself.

UPath AutoHotkey Script, is the script directly without other files.

Usage Examples

Example 1: UPath
Script := UPath("/bin/Scripts/Scriptname.ahk")
If ErrorLevel@UPath
    Run, %Script%

After first line of this code the variable Script could for example contain the following string D:\bin\Scripts\Scriptname.ahk. The global variable ErrorLevel@UPath is created atomatically and contains the number of items found and returned by UPath at last. If its not zero (greater than 0), then the next Run command would be executed here.

Example 2: RunUPath
RunUPath("/bin/Scripts/*.ahk", "notepad.exe")

RunUPath() will run directly all founded items. Any wildcard, like in this example will be extended to full path. The second argument is optional and specifies the program to start the founded file or folder with it, prior to that one which is actually registered with that filetype.

Example 3: Not simple
Path := UPath("//../*", "--subdirs --all --file", "UPath.*[^ks]+$")

Any path starting with two slashes will use the current scripts directory. In this example, the two dots are used, which means one up dir. This could for example be D:\home\ahkscripts\. There is an option defined file, which only let find files, no folders. The all means that all founded items would be returnd as a single semicolon separated list. The option subdirs means, that every subdirectory of given path will be searched also.

The second argument is a regular expression filter. Any path which does not match the filter, will not be found. Here, only a file if

will be found from UPath. The regex filter in UPath is always case insensitive.

All in one, the variable Path could for example contain the following string D:\Projects\UPath\UPath.history.txt;D:\Projects\UPath\upath.html;D:\Projects\UPath\UPath.man.txt.