From 91f45c72808042b7be3aca63c5a2399484f8b81f Mon Sep 17 00:00:00 2001 From: Khurram Malik Date: Thu, 16 Apr 2026 23:27:18 +0200 Subject: [PATCH] Fix #733: use PowerShell Move-Item for cross-volume directory moves on Windows Replace the robocopy-based .os.ren implementation with a simpler and more robust approach using PowerShell's Move-Item cmdlet. Move-Item natively handles: - File renames/moves - Directory renames/moves - Cross-volume moves (different Windows drives/disks) This fixes the WDB default writedown mode workflow when the WDB path and HDB path reside on different Windows drives/volumes. --- code/common/os.q | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/common/os.q b/code/common/os.q index db6ff4f20..90f86efec 100644 --- a/code/common/os.q +++ b/code/common/os.q @@ -14,11 +14,21 @@ hdeldir:{[dirpath;pdir] .lg.o[`deldir;"deleting from directory : ",dirpath]; hdel each desc filelist} md:{if[not Fex x;system"mkdir \"",pth[x],"\""]}; -ren:{system("mv ";"move ")[NT],pth[x]," ",pth y} cpy:{system("cp ";"copy ")[NT],pth[x]," ",pth y} Vex:not 0h~type key`.@ df:{(`$("/";"\\")[NT]sv -1_v;`$-1#v:("/";"\\")[NT]vs pth(string x;x)[10h=type x])} run:{system"q ",x} kill:{[p]@[(`::p);"\\\\";1];} sleep:{x:string x; system("sleep ",x;"timeout /t ",x," >nul")[NT]} -pthq:{[x] $[10h=type x;ssr [x;"\\";"/"];`$ -1 _ ssr [string (` sv x,`);"\\";"/"]]} \ No newline at end of file +pthq:{[x] $[10h=type x;ssr [x;"\\";"/"];`$ -1 _ ssr [string (` sv x,`);"\\";"/"]]} +ren:{[x;y] + / Convert the incoming q values into OS path strings. + src:pth x; + dst:pth y; + / On non-Windows platforms a normal mv already handles file and directory renames. + if[not NT; + :system "mv \"",src,"\" \"",dst,"\""]; + / Escape single quotes so a path can be embedded safely in a PowerShell literal string. + psqlit:{[p] "'",ssr[p;"'";"''"],"'"}; + / Move-Item gives us native Windows move semantics for files, directories and cross-volume moves. + :system "powershell -NoProfile -Command Move-Item -LiteralPath ",psqlit[src]," -Destination ",psqlit[dst]} \ No newline at end of file