Combining loopreadline with filecopy into subfolders Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Posts: 99
Joined: 18 Sep 2019, 02:06

Combining loopreadline with filecopy into subfolders

23 Jan 2020, 09:37

Hello again,
I am tweaking a script which I got from Thanks @flyingDman for your help with this script:

After trying it nothing happens, the file is not moved to the subfolders. Perhaps I've overcooked it.

goal of script

Read ID numbers from id.text file located inside the source folder.
for each of these ID numbers it will go to the matching subfolder inside the destination.
It will copy the email file called investigation reports complete.msg into each of these subfolders

Code: Select all

sourcepath := " C:\Users\JK\Documents\reports PDFs"
destpath := " C:\Users\JK\Documents\cases\xxxx"

Loop, Files, investigation reports complete.msg
	Loop, Read, C:\Users\JK\Documents\reports PDFs\id.txt	
	num := match1
	filecopy, C:\Users\JK\Documents\reports PDFs\investigation reports complete.msg,% destpath . floor(num/100) "01 - " ceil(num/100) "00\" num "\" A_LoopFileName         


Other things i tried

changed regexmatch to RegExReplace(A_LoopReadLine, "\d+",match)
changed num := match1 to num := match

Is there something simple I am missing here?

btw folder structure is like this C:\Users\JK\Documents\cases\2101 - 2200\2199
Posts: 26
Joined: 17 May 2015, 23:51

Re: Combining loopreadline with filecopy into subfolders  Topic is solved

23 Jan 2020, 13:58

This might do what your looking for or be close.

Code: Select all

sourcepath := a_mydocuments "\reports PDFs"
destpath := a_mydocuments "\cases"

Loop, Read,% sourcepath "\id.txt"	
	Loop,Files,% destpath "\*",d
		if ( regexmatch(A_LoopFileName,"" SubStr(num,1,2) "\d\d") ) {                  ; edited
			Loop,Files,% destpath "\" A_LoopFileName "\*",d
                                if(  regexmatch(A_LoopFileName,num)  )                                 ; edited
					,% sourcepath "\investigation reports complete.msg"
					,% A_LoopFileFullPath
first version crap. edited to be better and possibly work
Posts: 99
Joined: 18 Sep 2019, 02:06

Re: Combining loopreadline with filecopy into subfolders

25 Jan 2020, 04:56

Thanks for your reply @TravisQ,

The script works perfectly and amazingly.

Thank you

:dance: :bravo:

Return to “Ask For Help”

Who is online

Users browsing this forum: maneki, mikeyww, Rohwedder, RubbeH and 76 guests