Cynosure.X International

:

Add Comment | Related Links | TrackBack
Related Content

dirname.bat (GPL)

This "dirname.bat" is a Windows batch program that performs the same function as as the UNIX "dirname" command. And that function is to strip the child name from the parent path. You can call this script from your own custom batch script to extract the parent path.

"dirname.bat" takes advantage of the SetNumberOfArguments.bat (GPL) script that is available on this web site. So to use "dirname.bat", you'll have to download SetNumberOfArguments.bat, if you don't already have it.

"dirname.bat" is distributed as executable source code under the GNU General Public License. Please see the license agreement elsewhere on this site.

Usage

dirname.bat "path"

Examples

  > dirname "\Users\Medusa\Documents\My Games\Dawn of War 2"
\Users\Medusa\Documents\My Games

> dirname "Users\Medusa\Documents\My Games\Dawn of War 2"
Users\Medusa\Documents\My Games

Attached File: dirname.bat (761 B)

Chieh Cheng
Mon, 23 Feb 2009 10:19:19 +0000

I found a bug in "dirname.bat" where it would not correctly handle a remote Windows directory (a path that starts with two '\' characters). I fixed the problem in the version attached below.

Attached File: 1 - dirname.bat (835 B)

Chieh Cheng
Thu, 22 Apr 2010 06:38:14 +0000

I found another bug, where you only specify the name but no directory. I've fixed the code so that it outputs a '.' in such a case, which matches UNIX implementation. The fixed version is attached below.

Attached File: 2 - dirname.bat (900 B)

Chieh Cheng
Mon, 24 May 2010 20:20:28 +0000

The previous version of "dirname.bat" fails when the path contains parentheses. The version attached below fixes that problem.

Attached File: 3 - dirname.bat (1 KB)

Chieh Cheng
Mon, 02 Aug 2010 20:05:31 +0000

Found that the last fix introduced a bug that occurs when you do not specify a parent path or if the parent path is root. I've attached the fixed version below. The following are examples of correct output.

Examples

  > dirname.bat \bin
\

>dirname.bat "Hello World.txt"
.

Attached File: 4 - dirname.bat (1 KB)

Chieh Cheng
Thu, 02 Jun 2011 05:55:05 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 8 - 0?
Click button only once, please!

TrackBack

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

18 Users Online

Hacking Digital Cameras
Fun for Photographers


Amazon Associate

Copyright © 1996 - 2017. All Rights Reserved.