There are many reasons to prefer the use of forward slashes in filepaths on Windows.
Mostly because you often need to escape the slashes (\\) and sometimes even double escape them (\\\\) to get things working correctly. Especially when passing strings to other scripts or applications. Forward slashes are supported by the Windows filesystem so they usually work fine when passing commands to other applications, and makes programming much easier. However, the run("Image Sequence... command produces an incorrect image title including the full file path when using forward slashes. One would expect the image title to consist of only the last subpath. I am not sure of this is a pure Windows issue or not since I only use Windows. This behaviour is the same with both real and virtual stacks. Here is a macro demonstrating this issue: print("\\Clear"); run("Close All"); dir = getDirectory("temp"); //create a sample tiff virtual stack run("T1 Head (2.4M, 16-bits)"); File.makeDirectory(dir + "t1-head/"); run("Image Sequence... ", "format=TIFF save="+ dir + "t1-head/"); close(); print("Folder:" + dir); //outputs 'C:\Users\steinr\AppData\Local\Temp\' run("Image Sequence...", "open=" + dir + "t1-head/ sort"); print("Title:" + getTitle); //outputs 't1-head' //the image is correctly made from the last subpath //replace backslashes with forward slashes to avoid double escaping dir = replace(dir, "\\", "/"); print("Folder:" + dir); //outputs 'C:/Users/steinr/AppData/Local/Temp/' run("Image Sequence...", "open=" + dir + "t1-head/ sort"); print("Title:" + getTitle); //outputs 'C:/Users/steinr/AppData/Local/Temp/t1-head' //the image title now incorrectly includes the full path I am using daily build ImageJ 1.52f on Windows 7 64-bit. Stein -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> On Aug 20, 2018, at 6:22 AM, Stein Rørvik <[hidden email]> wrote:
> > There are many reasons to prefer the use of forward slashes in filepaths on Windows. > Mostly because you often need to escape the slashes (\\) and sometimes > even double escape them (\\\\) to get things working correctly. > Especially when passing strings to other scripts or applications. > Forward slashes are supported by the Windows filesystem so they usually work fine > when passing commands to other applications, and makes programming much easier. > > However, the run("Image Sequence... command produces an incorrect image title > including the full file path when using forward slashes. This bug is fixed in the latest ImageJ daily build (1.52f27). -wayne > One would expect the image title to consist of only the last subpath. > I am not sure of this is a pure Windows issue or not since I only use Windows. > > This behaviour is the same with both real and virtual stacks. > Here is a macro demonstrating this issue: > > print("\\Clear"); > run("Close All"); > dir = getDirectory("temp"); > > //create a sample tiff virtual stack > run("T1 Head (2.4M, 16-bits)"); > File.makeDirectory(dir + "t1-head/"); > run("Image Sequence... ", "format=TIFF save="+ dir + "t1-head/"); > close(); > > print("Folder:" + dir); > //outputs 'C:\Users\steinr\AppData\Local\Temp\' > run("Image Sequence...", "open=" + dir + "t1-head/ sort"); > print("Title:" + getTitle); > //outputs 't1-head' > //the image is correctly made from the last subpath > > //replace backslashes with forward slashes to avoid double escaping > dir = replace(dir, "\\", "/"); > print("Folder:" + dir); > //outputs 'C:/Users/steinr/AppData/Local/Temp/' > > run("Image Sequence...", "open=" + dir + "t1-head/ sort"); > print("Title:" + getTitle); > //outputs 'C:/Users/steinr/AppData/Local/Temp/t1-head' > //the image title now incorrectly includes the full path > > I am using daily build ImageJ 1.52f on Windows 7 64-bit. > > Stein -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |