Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Need help with - FileMoveDir



  • Please log in to reply
10 replies to this topic
Mily
  • Members
  • 147 posts
  • Last active: Mar 19 2016 07:00 PM
  • Joined: 10 Feb 2014

Hi,

 

I am trying to move Folders to a different location within the same computer (sometimes Network Shared Drives - Having all the access)

 

Please review my below code and let me know where I am doing the mistake. Files are not moving as expected.

Queue = E:\ABS\Queue\*.*
Done = E:\ABS\Transfer\Done
Error = E:\ABS\Transfer\Error

loop, %Queue%, 2, 1

{
	numFiles := 0
	thisFolder := A_LoopFileFullPath
	loop, %thisFolder%\*.*
	numFiles := A_Index
	if (numFiles<>5)
	{
		FileCopyDir, %thisFolder%, %Error%
		continue
	}
			Sleep, 500
}

; Do something here and there

FileMoveDir, %thisFolder%, %Done%
		Sleep, 500


AHK Version: v1.1.15.03 - OS: Windows 7 Ultimate - Browsers: IE 11 & Chrome - Editor: Notepad++ - Office 2010

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. Believe Yourself.
 


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Use A_LoopFileName instead of thisFolder, because, thisFolder contains the full path.

Replace this line :

		FileCopyDir, %thisFolder%, %Error%

by that line

		FileCopyDir, %A_LoopFileName%, %Error%

Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


Mily
  • Members
  • 147 posts
  • Last active: Mar 19 2016 07:00 PM
  • Joined: 10 Feb 2014

I have replaced but not working. Oh! btw FileMoveDir not FileCopyDir


AHK Version: v1.1.15.03 - OS: Windows 7 Ultimate - Browsers: IE 11 & Chrome - Editor: Notepad++ - Office 2010

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. Believe Yourself.
 


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

I was distracted, because I didn't notice it.


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


Mily
  • Members
  • 147 posts
  • Last active: Mar 19 2016 07:00 PM
  • Joined: 10 Feb 2014

Do you have any other solution about why it was not working.


AHK Version: v1.1.15.03 - OS: Windows 7 Ultimate - Browsers: IE 11 & Chrome - Editor: Notepad++ - Office 2010

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. Believe Yourself.
 


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Did you test it like this ?

		FileMoveDir, %A_LoopFileName%, %Error%

Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


ahcahc
  • Members
  • 129 posts
  • Last active: Sep 24 2016 08:15 AM
  • Joined: 21 Jun 2012

Filemovedir is outside the loop, the contents of thisFolder is the last folder found inside the loop. try placing it inside the loop with conditions that will trigger filemovedir.



Mily
  • Members
  • 147 posts
  • Last active: Mar 19 2016 07:00 PM
  • Joined: 10 Feb 2014

Script not working. Below snippet is from the autohotkey application.

 

014: Queue = E:\ABS\Queue\*.*
015: Done = E:\ABS\Transfer\Done
016: Error = E:\ABS\Transfer\Error
018: Loop,%Queue%,2,1
038: Return (11.19)
 
Script is halting at Loop.
 
Am I missing something.
 
@ ahcahc : Can you please rephrase the code if possible.

AHK Version: v1.1.15.03 - OS: Windows 7 Ultimate - Browsers: IE 11 & Chrome - Editor: Notepad++ - Office 2010

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. Believe Yourself.
 


ahcahc
  • Members
  • 129 posts
  • Last active: Sep 24 2016 08:15 AM
  • Joined: 21 Jun 2012
✓  Best Answer

 

Script not working. Below snippet is from the autohotkey application.

 

014: Queue = E:\ABS\Queue\*.*
015: Done = E:\ABS\Transfer\Done
016: Error = E:\ABS\Transfer\Error
018: Loop,%Queue%,2,1
038: Return (11.19)
 
Script is halting at Loop.
 
Am I missing something.
 
@ ahcahc : Can you please rephrase the code if possible.

 

the loop successfully completed and proceeded to execute line 38 (this is so probably because queue folder is now empty and lines 19-37 are inside the loop or commented out).

 

try this.

Queue = c:\ABS\Queue\*.*
Done = c:\ABS\Transfer\Done
Error = c:\ABS\Transfer\Error
loop, %Queue%, 2, 1 ;searching for folders only
{
numFiles := 0
;thisFolder := A_LoopFileFullPath    ;A_LoopFileFullPath=folder name with path
;A_LoopFileName=folder name without path
loop, %A_LoopFileFullPath%\*.*
numFiles := A_Index
if (numFiles<>5)
{
  FileCopyDir, %A_LoopFileFullPath%, %Error%\%A_LoopFileName%\, 1
  continue
}
else
  FileMoveDir, %A_LoopFileFullPath%, %Done%\%A_LoopFileName%\, 1
Sleep, 500
}


Mily
  • Members
  • 147 posts
  • Last active: Mar 19 2016 07:00 PM
  • Joined: 10 Feb 2014

Hi,

 

The Code works perfectly. The file count 5 right. Is it includes TEMP / hidden files. Like when MS Office documents temp file will be created in same location. 

 

As of now I may work-around on this code and I have another question to ask.

 

If in a folder 5 documents found and that folder contains only this files like (1.txt, 2.pdf, 3.pdf, 4.xlsx, 5.docx).

 

Can we run script based on this criteria. 


AHK Version: v1.1.15.03 - OS: Windows 7 Ultimate - Browsers: IE 11 & Chrome - Editor: Notepad++ - Office 2010

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. Believe Yourself.
 


ahcahc
  • Members
  • 129 posts
  • Last active: Sep 24 2016 08:15 AM
  • Joined: 21 Jun 2012

You can use A_LoopFileExt to check the extension of the files.