copy file to correct folder

Get help with using AutoHotkey and its commands and hotkeys
sbrady
Posts: 105
Joined: 15 Mar 2014, 20:41
Location: Virginia Beach

copy file to correct folder

22 Apr 2017, 07:52

I need to copy a file to a folder with similiar name. see attachment.
https://www.flickr.com/photos/sbrady19/ ... ed-public/

for example 04-22-17 OPEN MIX.png
needs to be copied to the 04-22-17 OPEN EXPORTS folder

here is my attempt.
get a list of the folders
loop thru the folder for the mix files
if a file has same name as a folder, copy that file to that folder.

Any help would be appreciated

Code: Select all

the_list = 
Loop, C:\Users\DAW3\Desktop\future shows\*,2
{
StringLeft, 14char, A_LoopFileName, 14
;msgbox, %14char%
the_list = %the_list%`n%14char%
}
;msgbox, %the_list%




Loop, C:\Users\DAW3\Desktop\future shows\* mix.png,
{
StringLeft, 14char_mix, A_LoopFileName, 14
msgbox, %14char_mix%
IfInString, the_list, 14char_mix
msgbox, yes
}
TravisQ
Posts: 15
Joined: 17 May 2015, 23:51

Re: copy file to correct folder

22 Apr 2017, 15:02

If your naming convention doesnt change maybe something like this could work for you,

Code: Select all

FilePattern := A_Desktop "\future shows\*"
Loop, Files, %FilePattern% , f
{		
		file := A_LoopFileName , filePath := A_LoopFileLongPath
		RegExMatch( file,"(.+?) (.+?) ", fileData )
	Loop, Files, %FilePattern% , d 
	{
		folder := A_LoopFileName , folderPath := A_LoopFileLongPath
		RegExMatch( folder,"(.+?) (.+?) ", folderData )
		If ( filedata1=folderdata1 ) {
		  If ( filedata2=folderdata2 ) {
			MsgBox,4,,Copy:`n`t %file% `nto:`n`t%folder% ?
			IfMsgBox,yes
				FileCopy, %filePath%, %folderPath%, 0
	}	} }
}
sbrady
Posts: 105
Joined: 15 Mar 2014, 20:41
Location: Virginia Beach

Re: copy file to correct folder

23 Apr 2017, 14:35

the lightbulb goes on and I always figure it out AFTER I post for help. Works like a charm. Cant believe it was so simple. Thanks for all your help.

Code: Select all

;loop the files for mix in their name
Loop, C:\Users\DAW3\Desktop\future shows\* mix.png,
{
StringLeft, 16char_mix, A_LoopFileName, 16
the_mix = %A_LoopFileFullpath%

        ;loop the folders for the same 1st 16 characters
	Loop, C:\Users\DAW3\Desktop\future shows\*,2
	{
	the_export_folder = %A_LoopFileFullpath%
	IfInString, the_export_folder, %16char_mix%
	;msgbox, %the_export_folder%
	filecopy, %the_mix%,%the_export_folder%
	}
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, Google [Bot], omar, Spikea and 201 guests