Why does filemove not work with variables? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
xyz

Why does filemove not work with variables?

21 Aug 2017, 13:23

With msgbox, I check that the paths/names are correct; I also check that the file does not exist yet in the target folder. I also check that no application is retaining the files-to-be-moved in the original folder. I always just try to move one file, but a different one each time, with no success for any of them. The strings don't contain any spaces. The filemove command with just strings works fine, it's when I use variables that nothing works: errorlevel and "0 files moved":

Code: Select all

fullpath := "path1\thefile.ext"
targetpath := "path2\"
msgbox, _%fullpath%_`n_%targetpath%_ ; both correct

filemove, %fullpath%, %targetpath%, 0 ; does nothing, while a

filemove, path1\thefile.ext, path2\, 0 ; then works for that very same file...
Any ideas?
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Why does filemove not work with variables?

21 Aug 2017, 13:54

Code: Select all

fullpath := "path1\thefile.ext"
targetpath := "path2\"
msgbox, _%fullpath%_`n_%targetpath%_ ; 
filemove, %fullpath%, %targetpath%, 0 ; 
I tested this on my computer and it works, the folder "path1" and "path2" was in the same folder as the script. So there must be something else going on in your script
xyz

Re: Why does filemove not work with variables?  Topic is solved

21 Aug 2017, 14:34

Thank you very much, Rindis, you are right.

Original data came from wingettitle where I deleted the generic (last) part in order to get the full source path; on some files only, that application had additional parts AFTER its generic part, though, so instead of stringtrimright, I needed to get the path by

Code: Select all

pos := instr(title, genericpart,, 0, 1)
title := substr(title, 1, pos-1)
Also, I had some unwanted "0" directly after some variable, obviously by typing that inadvertently myself, or it being typed by the cat (she avoids the keys of the keyboard, but the num0 is very near its border), so some variable then didn't get the correct value anymore (I'd prefer to be able to "really" declare AHK variables, but that's not possible, unfortunately, so mistyped variables can never be excluded).

Now it works fine; thank you very much again!
thixjf
Posts: 2
Joined: 26 May 2024, 18:51
Contact:

Re: Why does filemove not work with variables?

26 May 2024, 18:54

not string:="caminho\text"
yes string=caminho\text
gregster
Posts: 9116
Joined: 30 Sep 2013, 06:48

Re: Why does filemove not work with variables?

26 May 2024, 19:47

thixjf wrote:
26 May 2024, 18:54
not string:="caminho\text"
yes string=caminho\text
Are you trying to say that only the second assignment would work? That's not correct.
In AHK v1, both methods are equivalent - and in AHK v2, only the first one would work.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 157 guests