MSF Posted May 26, 2009 Share Posted May 26, 2009 I have over 70,000 .tiff's stored in a window's directory. These tiff's are named with customer ID's followed by an "r" or "c". I need to move all the tiff's that match a customer ID to a different directory. I have tried the dos command move 1234*.tiff, 4456*.tiff folder but that doesn't work (despite the fact dos help says it should). Any ideas how I can use AutoIT to automate this? Thanks in advance! Link to comment Share on other sites More sharing options...
martin Posted May 26, 2009 Share Posted May 26, 2009 I have over 70,000 .tiff's stored in a window's directory. These tiff's are named with customer ID's followed by an "r" or "c". I need to move all the tiff's that match a customer ID to a different directory. I have tried the dos command move 1234*.tiff, 4456*.tiff folder but that doesn't work (despite the fact dos help says it should). Any ideas how I can use AutoIT to automate this? Thanks in advance! The DOS command would be MOVE 1234*.TIFF folder\4456*.TIFF assuming the command prompt is operating in th efolder where the 1234*.TIFF files are. The FileMove function in AutoIt will do the job. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
muncherw Posted May 26, 2009 Share Posted May 26, 2009 I have over 70,000 .tiff's stored in a window's directory. These tiff's are named with customer ID's followed by an "r" or "c". I need to move all the tiff's that match a customer ID to a different directory. I have tried the dos command move 1234*.tiff, 4456*.tiff folder but that doesn't work (despite the fact dos help says it should). Any ideas how I can use AutoIT to automate this? Thanks in advance!The moving part is easy. Just look up filemove in the helpfile. FileMove("C:\1234*.tiff", "C:\NewFolder\1234.tiff") You might want to use something like FileGetLongName to get names and then you could make the folder's based on that. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
MSF Posted May 26, 2009 Author Share Posted May 26, 2009 I've got a rough idea of how to do this in my head, and I believe you'll need these functions.InputBox - Ask for the customer ID. You'll only want the numbers.FileFindFirstFile - Open a search handle.Start a While LoopFileFindFirstFile - Use the search handle to go through all the files.StringInStr - Use this to see if the file name contains the customer ID.FileMove - Move the files.End the While loopThanks! But with over a million customer ids to compare 70+ thousand files to, I would need this to be behind the scenes. Link to comment Share on other sites More sharing options...
muncherw Posted May 26, 2009 Share Posted May 26, 2009 Once you get the names you you can use StringLeft and StringRight to cut off the leading r or c and the trailing .tiff. Use that info to automatically create your folders. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
muncherw Posted May 26, 2009 Share Posted May 26, 2009 This should be pretty easy to do I would think. Do you have any code at all for us to look at right now? Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
MSF Posted May 26, 2009 Author Share Posted May 26, 2009 This should be pretty easy to do I would think. Do you have any code at all for us to look at right now?Not yet. I'm working on Thanubis' suggestion right now. Link to comment Share on other sites More sharing options...
MSF Posted May 26, 2009 Author Share Posted May 26, 2009 (edited) Here is what I have so far. It needs a lot of work. Not sure if I'm even on the right track. #include <File.au3> Global $sourceFile = "C:\test\Scanned\ValidCust.txt" ; contains numeric customer ids like 1234 Global $dest = "C:\test\BacklogInbox" ; directory to put the file if it is found in ValidCust.txt Global $custID = ; need to make this first cust id in $sourceFile $search = FileFindFirstFile($custID&="*.tiff") ; trying to find 1234*.tiff While 1 $file = FileFindNextFile($search) ; Need to loop through all ID's in $sourceFile, moving any matches to $dest FileMove($file, $dest) WEnd FileClose($search) Edited May 26, 2009 by MSF Link to comment Share on other sites More sharing options...
muncherw Posted May 27, 2009 Share Posted May 27, 2009 That was a good start. I've made a few changes, some fixes and some basic error checking. It seemed to work fine during the little bit of testing that I did.EDIT: Also, with the way this is currently set up, it will only work if you run it from the directory where the .tiff files are.Looks good to me. I was hoping to work on this some myself last night but you beat me to it. Nice work. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
MSF Posted May 27, 2009 Author Share Posted May 27, 2009 Thanks for the help guys! I was on #autoIT @ irc.freenode.net last night. A mod that goes by the irc handle SmOke_N was able to help me come to a solution. #include <array.au3> Local $s_file_with_ids = "C:\test\Scanned\ValidCust.txt" ; @HomeDrive & "\ValidCustomers.txt" Local $s_main_tiff_directory = "C:\test\Scanned\" ; @HomeDrive & "\tiff_test_dir\" Local $s_transfer_to_directory = "C:\test\BacklogInbox\";@HomeDrive & "\tiff_send_to_dir\" Local $a_find_ids = StringRegExp(FileRead($s_file_with_ids), "(\d+)", 3) If @error Then MsgBox(16, "Error", "No id's found or FileRead() failed!") Exit EndIf Local $a_record[UBound($a_find_ids)], $i_c = 0 ; These are not neccessary if you uncomment the filemove, and comment the $a_record[$i_c] = For $i = 0 To UBound($a_find_ids) - 1 If FileMove($s_main_tiff_directory & $a_find_ids[$i] & "c.tiff", $s_transfer_to_directory & $a_find_ids[$i] & "c.tiff", 8) Then $a_record[$i_c] = $s_main_tiff_directory & $a_find_ids[$i] & "c.tiff" $i_c += 1 EndIf If FileMove($s_main_tiff_directory & $a_find_ids[$i] & "r.tiff", $s_transfer_to_directory & $a_find_ids[$i] & "r.tiff", 8) Then $a_record[$i_c] = $s_main_tiff_directory & $a_find_ids[$i] & "r.tiff" $i_c += 1 EndIf Next ;ReDim $a_record[$i_c] ;_ArrayDisplay($a_record, "All files that will be transferred") Link to comment Share on other sites More sharing options...
muncherw Posted May 27, 2009 Share Posted May 27, 2009 Thanks for the help guys! I was on #autoIT @ irc.freenode.net last night. A mod that goes by the irc handle SmOke_N was able to help me come to a solution.If you spend any time at all on the forums you'll see his name all over the place. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now