Advertisement
jdm001

AutoHotKey FileCopy Troubleshooting

Oct 26th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; -- Trying to copy a background across many devices, the path has two spaces that I cannot change --
  2. ; -- I can copy using FileCopyDir without issue, but that copies too many files.
  3. ; -- For some reason FileCopy, *.filetype won't work.  It's giving "file not found" error, i think on source.
  4. ; -- I tried creating the directory in advance, but even when path directory exists I get same error!
  5. ; -- Here's what I tried:
  6.  
  7. ; This doesn't work at all, error from dll call says "2" which is "file not found"
  8. FileCopy, D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg, %A_WorkingDir%\SettingsSaver\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)
  9. If ErrorLevel
  10.    {
  11.    ; MsgBox, Command = FileCopy, `n D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg, `n %A_ScriptDir%\SettingsSaver\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg
  12.    DllCall("CopyFile", "Str", "SourcePathAndFile", "Str", "DestPathAndFile", Int, 0) ;Last parameter is over-write flag
  13.    MsgBox %A_LastError%
  14.    }
  15.  
  16. ; Tried again as above but this time one specific file, same error
  17. FileCopy, D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\JoyToKey.ini, %A_ScriptDir%\SettingsSaver\Arcade\Tools\JoyToKey_en 5.8.1 (CLM)\JoyToKey.ini
  18.  
  19.  
  20. ; set variable in case double spaces or parenthesis are issue in directory
  21. BadDir = Arcade\Tools\JoyToKey_en  5.8.1 (CLM)
  22.  
  23. ; Tried using the variable I set in previous line, same error
  24. FileCopy, D:\%BadDir%\AppLink.dat, %A_ScriptDir%\SettingsSaver\%BadDir%\AppLink.dat
  25. MsgBox  D:\%BadDir%\AppLink.dat, %A_ScriptDir%\SettingsSaver\%BadDir%\AppLink.dat
  26. If ErrorLevel
  27.    {
  28.    ; MsgBox, Command = FileCopy, `n D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg, `n %A_ScriptDir%\SettingsSaver\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg
  29.    DllCall("CopyFile", "Str", "SourcePathAndFile", "Str", "DestPathAndFile", Int, 0) ;Last parameter is over-write flag
  30.    MsgBox %A_LastError%
  31. }
  32. MsgBox, Saved Controller Configurations!
  33.  
  34.  
  35. ; I try from dos instead. Error said "The system cannot find the path specified.  0 file(s) copied"
  36. ; I think it's new path not source path.   I think it's finding files in source, but won't create directory.
  37. Runwait, %comspec% /k copy "D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg" "%A_WorkingDir%\SettingsSaver\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg"
  38.  
  39. ; Tried using variable too.  Nope.
  40. Runwait, %comspec% /k copy "D:\%BadDir%\AppLink.dat" "%A_ScriptDir%\SettingsSaver\%BadDir%\AppLink.dat"
  41.  
  42. ; On second occurance of variable, i got a weird missing variable.  Does variable reset on error?
  43. ; The next line below caused this error:  http://imgur.com/a/FtE4U
  44. Runwait, %comspec% /k copy "D:\%BadDir%\AppLink.dat" "%A_ScriptDir%\SettingsSaver\%BadDir%\AppLink.dat"
  45.  
  46. ; Tried copying to a plain directory "j2k" and then renaming, still couldn't find path.
  47. Runwait, %comspec% /c copy copy "D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM)\*.cfg" "c:\users\theba\desktop\new folder\j2k\*.cfg" && ren j2k "JoyToKey_en  5.8.1 (CLM)"
  48.  
  49. ; But this works, no issue.  The FileCopyDir.  Why can it find directory but not files????????
  50. FileCopyDir, D:\Arcade\Tools\JoyToKey_en  5.8.1 (CLM), %A_ScriptDir%\SettingsSaver\Arcade\Tools\JoyToKey_en
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement