Skip to main content

CreateAliasShortcut

CreateAliasShortcut [/D/I[=i ]/M=messageStr /O/P=pathName /S=saveMessageStr /Z[=z ] ] [targetFileDirStr ] [ as shortcutFileStr ]

The CreateAliasShortcut operation creates a shortcut file on disk. The shortcut can point to either a file or a folder. The file or folder pointed to is called the "target" of the shortcut.

Before Igor 10, Igor Macintosh versions supported aliases, which are equivalent to Windows shortcuts.

Parameters

targetFileDirStr can be a full path to the file or folder to make a shortcut for, a partial path relative to the folder associated with /P=pathName, or the name of a file or folder in the folder associated with pathName.

If Igor cannot determine the location of the file or folder from targetFileDirStr and pathName, it displays a dialog allowing you to specify a target file. Use /D to select a folder as the shortcut target, instead.

shortcutFileStr can be a full path to the created shortcut file, a partial path relative to the folder associated with pathName if specified, or the name of a file in the folder associated with pathName. Both Windows-formatted and Macintosh-formated file paths are supported.

If Igor cannot determine the location of the shortcut file from shortcutFileStr and pathName, it displays a File Save dialog allowing you to create the file.

If you use a full or partial path for either targetFileDirStr or shortcutFileStr, see Path Separators for details on forming the path.

Folder paths should not end with single Path Separators. See MoveFolder's Details section.

Flags

/DUse the Select Folder dialog rather than Open File dialog when targetFileDirStr is not fully specified.
/I[=i ]Specifies the level of user interactivity.
i =0:Interactive only if one or targetFileDirStr or shortcutFileStr is not specified or if the target file is missing. (Same as if /I was not specified.)
i =1:Interactive even if targetFileDirStr is fully specified and the target file exists.
i =2: ::Interactive even if targetFileDirStr is specified.
i =3: ::Interactive even if targetFileDirStr is specified and
/M=messageStrSpecifies the prompt message in the Open File or Select Folder dialog. If /S is not specified, then messageStr will be used for Open File (or Select Folder) and for Save File dialogs.
/OOverwrites any existing file with the shortcut file.
/P=pathNameSpecifies the folder to look in for the file. pathName is the name of an existing symbolic path.
/S=saveMessageStrSpecifies the prompt message in the Save File dialog when creating the shortcut file.
/Z[=z ]Prevents procedure execution from aborting if the procedure tries to create a shortcut for a file or folder that does not exist. Use /Z if you want to handle this case in your procedures rather than having execution abort.
/Z=0:Same as no /Z at all.
/Z=1:Creates a shortcut to a file or folder only if it exists. /Z alone has the same effect as /Z=1.
/Z=2:Creates a shortcut to a file or folder only if it exists and displays a dialog if it does not exist.

Variables

The CreateAliasShortcut operation returns information in the following variables:
V_Flag
0:Created a shortcut file.
-1:User cancelled any of the Open File, Select Folder, or Save File dialogs.
Other:An error occurred, such as the target file does not exist.
S_pathFull path to the created shortcut file. If an error occurred or if the user cancelled, it is an empty string.
S_fileNameFull path to the target file or folder. If an error occurred or if the user cancelled, it is an empty string.

Examples

// Create a shortcut to the current experiment on the Desktop
String target= Igorinfo(1)+".pxp" // experiment files have .pxp extensions
CreateAliasShortcut/O/P=home target as "C:\\Users\\myName\\Desktop\\"+target // explicit Windows file path style
Print S_fileName // Full path to target (Mac file path style)
Print S_path // Full path to the created shortcut file (Mac file path style)

// Same example using Mac file path style returned from SpecialDirPath
String desktopPath = SpecialDirPath("Desktop", 0, 0, 0) // mac file path with ending ":" separator
String shortcutPath = desktopPath+target
CreateAliasShortcut/O/P=home target as shortcutPath
Print S_fileName // Full path to target (Mac file path style)
Print S_path // Full path to the created shortcut file (Mac file path style)

// Reveal the desktop in Windows Explorer
NewPath/O/Q Desktop, desktopPath
PathInfo/SHOW Desktop

See Also

Open, MoveFile, DeleteFile, GetFileFolderInfo, IgorInfo, Symbolic Paths, ParseFilePath