I want to use a function in my script, that does a fair amount of converting windows paths (with / without filenames) into unix paths.
The function gets an input (global variable) which can contain:
1.) one single windows path without a file name; e.g. <curpath>
2.) one single windows path with a file name; e.g. <curitem>
3.) a | separated list of windows paths with file names; e.g. get("SelectedItemsPathNames", "|");
It won't get a list with a | separated mix of paths with and without file names (when a user would select a file and a dir in the same directory).
Input examples:
Code: Select all
1.) D:\Users\Highend\Tools\Steuer Erklärung
2.) D:\Users\Highend\Tools\Steuer Erklärung\Jahr 2010.pdf
3.) D:\Users\Highend\Tools\Steuer Erklärung\Jahr 2010.pdf|D:\Users\Highend\Tools\Steuer Erklärung\Jahr 2011.pdf
Code: Select all
1.) /Users/Highend/Tools/Steuer Erklärung
$CTU_SelectedItems contains input example 1, 2 or 3.
Code: Select all
$WindowsPath = $CTU_SelectedItems;
$UnixPath = regexreplace($WindowsPath, "([A-Za-z]):", "");
$UnixPath = replace($UnixPath, "\", "/");
Code: Select all
1.) /Users/Highend/Tools/Steuer Erklärung
or
2.) /Users/Highend/Tools/Steuer Erklärung/Jahr 2010.pdf
or
3.) /Users/Highend/Tools/Steuer Erklärung/Jahr 2010.pdf|/Users/Highend/Tools/Steuer Erklärung/Jahr 2011.pdf
So:
Code: Select all
$UnixPath = regexreplace($UnixPath, "???", "$1");
highend