I'm simply trying to copy a folder to another, but DirCopy keeps failing and I'm not sure why...
#Requires AutoHotkey v2.0
clipboard := A_Clipboard
arr := StrSplit(clipboard, "`n")
source_folder := "C:\Users\####\Documents\AutoHotkey\WT"
destination_folder := "C:\Users\###\Documents\AutoHotkey\PSDT"
Loop arr.length
{
name_part := arr[A_Index]
sps := StrSplit(name_part, A_Tab)
name_part := sps[1]
ep := sps[2]
aim := ""
dos := "FR " name_part " " ep
Loop Files, source_folder "\FR " name_part "*", "D"
aim := A_LoopFilePath
aim := Trim(aim "\" dos)
MsgBox ". " aim
MsgBox "> " destination_folder "\" dos
if DirExist(aim)
MsgBox "The target folder does exist."
DirCreate destination_folder "\Folder"
DirCopy( aim, destination_folder "\" dos)
}
The Folder
is created and the aim does exist.
I've tried to launch the script in admin mode (right-click : run as administrator)
Does anyone has an idea why this Exception is occurring?
Okay! I've found the solution!
The problem came from the very source. The clipboard was filled from 4 cells in a sheet.
I thought the structure was
Elmt1 \t Elmt2 \n
Elmt3 \t Elmt4 \n
But it was not just a Line Feed, but a End Of Line instead. So, the line to fix was at the beginning, corrected like this:
arr := StrSplit(clipboard, "`r`n")