CYGPATH(1) CYGWIN CYGPATH(1)NAME
- Convert Unix and Windows format paths, or output system path infor‐
mation
SYNOPSIScygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...
cygpath [-c HANDLE]
cygpath [-ADHOPSW]
cygpath [-F ID]
OPTIONS
Output type options:
-d, --dos
print DOS (short) form of NAMEs (C:\PROGRA~1\)
-m, --mixed
like --windows, but with regular slashes (C:/WINNT)
-M, --mode
report on mode of file (currently binmode or textmode)
-u, --unix
(default) print Unix form of NAMEs (/cygdrive/c/winnt)
-w, --windows
print Windows form of NAMEs (C:\WINNT)
-t, --type TYPE
print TYPE form: 'dos', 'mixed', 'unix', or 'windows'
Path conversion options:
-a, --absolute
output absolute path
-l, --long-name
print Windows long form of NAMEs (with -w, -m only)
-p, --path
NAME is a PATH list (i.e., '/bin:/usr/bin')
-s, --short-name
print DOS (short) form of NAMEs (with -w, -m only)
-C, --codepage CP
print DOS, Windows, or mixed pathname in Windows codepage CP.
CP can be a numeric codepage identifier, or one of the reserved
words ANSI, OEM, or UTF8. If this option is missing, cygpath
defaults to the character set defined by the current locale.
System information:
-A, --allusers
use `All Users' instead of current user for -D, -P
-D, --desktop
output `Desktop' directory and exit
-H, --homeroot
output `Profiles' directory (home root) and exit
-O, --mydocs
output `My Documents' directory and exit
-P, --smprograms
output Start Menu `Programs' directory and exit
-S, --sysdir
output system directory and exit
-W, --windir
output `Windows' directory and exit
-F, --folder ID
output special folder with numeric ID and exit
Other options:
-f, --file FILE
read FILE for input; use - to read from STDIN
-o, --option
read options from FILE as well (for use with --file)
-c, --close HANDLE
close HANDLE (for use in captured process)
-i, --ignore
ignore missing argument
-h, --help
output usage information and exit
-v, --version
output version information and exit
DESCRIPTION
The cygpath program is a utility that converts Windows native file‐
names to Cygwin POSIX-style pathnames and vice versa. It can be used
when a Cygwin program needs to pass a file name to a native Windows
program, or expects to get a file name from a native Windows program.
Alternatively, cygpath can output information about the location of
important system directories in either format.
The -u and -w options indicate whether you want a conversion to UNIX
(POSIX) format ( -u) or to Windows format ( -w). Use the -d to get
DOS-style (8.3) file and path names. The -m option will output Win‐
dows-style format but with forward slashes instead of backslashes.
This option is especially useful in shell scripts, which use back‐
slashes as an escape character.
In combination with the -w option, you can use the -l and -s
options to use normal (long) or DOS-style (short) form. The -d option
is identical to -w and -s together.
The -C option allows to specify a Windows codepage to print DOS and
Windows paths created with one of the -d, -m, or -w options. The
default is to use the character set of the current locale defined by
one of the internationalization environment variables setup-locale
/xref. This is sometimes not sufficent for interaction with native
Windows tools, which might expect native, non-ASCII characters in a
specific Windows codepage. Console tools, for instance, might expect
pathnames in the current OEM codepage, while graphical tools like Win‐
dows Explorer might expect pathnames in the current ANSI codepage.
The -C option takes a single parameter:
ANSI, to specify the current ANSI codepage
OEM, to specify the current OEM (console) codepage
UTF8, to specify UTF-8.
A numerical, decimal codepage number, for instance 936 for GBK, 28593
for ISO-8859-3, etc. A full list of supported codepages is listed on
the Microsoft MSDN page -C hasn't been specified at all.
The -p option means that you want to convert a path-style string
rather than a single filename. For example, the PATH environment vari‐
able is semicolon-delimited in Windows, but colon-delimited in UNIX.
By giving -p you are instructing cygpath to convert between these
formats.
The -i option supresses the print out of the usage message if no file‐
name argument was given. It can be used in make file rules converting
variables that may be omitted to a proper format. Note that cygpath
output may contain spaces (C:\Program Files) so should be enclosed in
quotes.
cygpath usage
#!/bin/sh
if [ "${1}" = "" ];
then
XPATH=".";
else
XPATH="$(cygpath -C ANSI -w "${1}")";
fi
explorer $XPATH &
The capital options -D, -H, -P, -S, and -W output directories used
by Windows that are not the same on all systems, for example -S might
output C:\WINNT\system32 or C:\Windows\System32. The -H shows the
Windows profiles directory that can be used as root of home. The -A
option forces use of the "All Users" directories instead of the cur‐
rent user for the -D, -O and -P options. The -F outputs other spe‐
cial folders specified by their internal numeric code (decimal or
0xhex). For valid codes and symbolic names, see the CSIDL_* definitions
in the include file /usr/include/w32api/shlobj.h from package w32api.
The current valid range of codes for folders is 0 (Desktop) to 59
(CDBurn area). By default the output is in UNIX (POSIX) format; use
the -w or -d options to get other formats.
COPYRIGHT
Cygwin is Copyright (C) 1995-2010 Red Hat, Inc.
Cygwin is Free software; for complete licensing information, refer to:
http://cygwin.com/licensing.html
SEE ALSO
The full documentation to the Cygwin API is maintained on the web at:
http://cygwin.com/cygwin-api/cygwin-api.html
The website is updated more frequently than the man pages and should be
considered the authoritative source of information.
April 2010 CYGPATH(1)