FileMove wont move more than 1 files

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

FileMove wont move more than 1 files

05 Aug 2017, 11:17

Hello guys! I had to attract you with that simple title, but in reality it is not that simple of a problem

The following script is part of another big script to auto print files on a folder.

Code: Select all

WatchMove:
    IfExist C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
    {
        Loop, C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
        {
            FileLongName = %A_LoopFileLongPath%
            FileMove, %A_LoopFileLongPath%, D:\Print,1
        }
    }
Return
I have set WatchMove as a Settimer, 200 so it can watch and move any incoming files (Pictures) from my Google Drive Folder.

The Problem is that sometimes 2 files get synced at once and WatchMove wont move the second file, only the first file which is strange to me...

So I have tested this and confirmed...

- Copy Pasted 1 file in the folder, waited 2 seconds, pasted another file... They both moved.
- Copy Pasted 2 files in the folder at the same time... only the 1st file got moved... unless I reset the WatchMove Settimer by turning it on and off. It would never detect the 2nd File...

why does this happen and is there a fix?
Vh_
Posts: 203
Joined: 17 Mar 2017, 22:06

Re: FileMove wont move more than 1 files

05 Aug 2017, 12:34

Are the file names the same name? I know that if they already exist in the directory they are going to, it wont move them.
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: FileMove wont move more than 1 files

05 Aug 2017, 12:53

Vh_ wrote:Are the file names the same name? I know that if they already exist in the directory they are going to, it wont move them.

No, the file names are never the same. I know that because I tested moving them as I said, individually (which succeeded) and at the same time( which failed) and also the file names are named from my phone's whatsapp by time. something like 20170705_img02.jpg something like that.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: FileMove wont move more than 1 files

05 Aug 2017, 13:36

Instead of looping the folder you could use filepattern in the filemove command:

Code: Select all

WatchMove:
    IfExist C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
		FileMove, C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg, D:\Print, 1
Return
Another issue that can happen is you cant move a file if its still being written to.

HTH
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: FileMove wont move more than 1 files

05 Aug 2017, 16:21

Xtra wrote:Instead of looping the folder you could use filepattern in the filemove command:

Code: Select all

WatchMove:
    IfExist C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg
		FileMove, C:\Users\%A_UserName%\Google Drive\WhatsApp_Pics\*.jpg, D:\Print, 1
Return
Another issue that can happen is you cant move a file if its still being written to.

HTH
I believe the file is still syncing on google drive? but that is unlikely because I tested the paste 1 file then wait 1 second paste another file and that worked... but pasting 2 files at once did not work...

I honestly have no idea what else to do...

here is the code https://justpaste.it/19r34
KeypressGuy
Posts: 16
Joined: 17 Jul 2017, 16:55

Re: FileMove wont move more than 1 files

07 Aug 2017, 08:41

Here's a piece out of the Loop (files & folders) section of the help file. Instead of using the wildcard match, try handling each file individually. Use code like this to read the directory, then put in a delay before you start accessing the JPGs to give any that are not ready to be accessed time to become ready.

Code: Select all

FileList =
Loop, Files, *.jpg
   FileList = %FileList%%A_LoopFileName%`n
Loop, Parse, FileList, `n
   FileMove, %A_LoopField%, renamed_%A_LoopField%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, Oblomov228, PsysimSV, uchihito and 190 guests