ShaSha Posted April 13, 2016 Share Posted April 13, 2016 I have been using Autoitv3 for several months. The only reason I use it is to use a script to find a list of part numbers in a text file in and image folder and copy those specific images to an output file on my desktop. I know nothing about coding or scripting and I was lucky enough to find the script in a forum (Seven Forums) and it worked like a dream. BUT not it has stopped finding the images and reports as if they are not in the file and I don't know why. I am using Windows 7 64-bit operating system. I will attach the script I am using. I get requests daily of 100 or more part numbers that a customer needs images for. With over 35,000 images in the file this program is a complete lifesaver for me! Thank you so much if you can please help me! Marsha Find Images.au3 Link to comment Share on other sites More sharing options...
alien4u Posted April 13, 2016 Share Posted April 13, 2016 Hi @ShaSha Post your code, not an image and also post what error are you getting? Regards Alien. Link to comment Share on other sites More sharing options...
MattHiggs Posted April 13, 2016 Share Posted April 13, 2016 Could you please clarify what it is the program is doing exactly. Is it that you are searching the contents of text files for image names/paths and want to copy the images from one folder to another? Your description is kind of confusing.... Link to comment Share on other sites More sharing options...
ShaSha Posted April 13, 2016 Author Share Posted April 13, 2016 The script is attached right above the images, it is a link. I'm sorry to be confusing. I have a list of numbers in a text file and a folder full of image files. When I execute the script it asks me to select the folder containing the list. Then it asks me to select the folder containing the images. Then it WAS searching the image folder and copying those matching numbers (number from list & Image name) and creating an output folder on the desktop containing those images only. Instead of having to search the folder one by one it would automatically copy them. I'm not getting an error on the program or script side as far as I can tell. It is only saying it could not find the images in that particular folder. I know the filename with that number is actually in the folder. Hope this helps...I'm pretty good with a computer just not this stuff =/ Link to comment Share on other sites More sharing options...
ShaSha Posted April 13, 2016 Author Share Posted April 13, 2016 script.txt Link to comment Share on other sites More sharing options...
alien4u Posted April 13, 2016 Share Posted April 13, 2016 Your error look like 355000201 is not found on this folder, maybe because is not there or is not an image? what about extension? .jpg, .bmp I don't see that on your code, your list is coming with extensions? example: 355000201.jpg? or just names? Regards Alien. ShaSha 1 Link to comment Share on other sites More sharing options...
ShaSha Posted April 13, 2016 Author Share Posted April 13, 2016 You are right. Ahhhh so I was searching before it stopped working with the extension included .jpg, .tif. and it seems I am now searching without. So I have to have the complete filename with the extension in the list? I could have swore I searched using just the part number and it would output all files that had the same number in the file name. For example: 355007451.TOPP.jpg 355007451.TOPP.tif 355007451.dia.jpg 355007461.FRNT.jpg 355007461.FRNT.tif Is there a way to add into the code to not need the extension to just search for all files with say 355007451 part number in it? Thank you for your help!!!! Link to comment Share on other sites More sharing options...
alien4u Posted April 13, 2016 Share Posted April 13, 2016 There is multiples way to do this you should read the Help File and understand what are you doing, understand the code so you can fix future problems. Anyways here is one fix only one line need to be modify: If $file = $FileNameArray[$i]&".jpg" Or $file = $FileNameArray[$i]&".tif" Then Regards Alien. Link to comment Share on other sites More sharing options...
ericbartha Posted April 13, 2016 Share Posted April 13, 2016 (edited) @alien4u, why not just use a wildcard so it ignores filenames altogether? Generally speaking, part numbers are a unique identifier so it should not be an issue. Edited April 14, 2016 by ericbartha Link to comment Share on other sites More sharing options...
alien4u Posted April 13, 2016 Share Posted April 13, 2016 1 hour ago, ericbartha said: @alien4u, why not just use a wildcard so it ignores filenames altogether? Generally speaking, part numbers are a unique identifier so it should not be an issue. Instead of alien4u's code, try this replacement line If $file = $FileNameArray[$i] & ".*" Then Hi @ericbartha Maybe because with wildcard like that this don't work? $FileNameArray[$i] store a value, in this case an string and with & (concatenation) you add to the end of that string ".jpg" or anything you wish... In your example you are adding ".*" so this is not going to work because the script will search for $FileNameArray[$i](the value inside that).* Regards Alien. Link to comment Share on other sites More sharing options...
iamtheky Posted April 13, 2016 Share Posted April 13, 2016 (edited) If this script was in the parent folder, it would search through all of the files, return the ones that match the searchstring, and copy them to the testcopy folder. You can comment out the arraydisplay once you decide it is returning the correct targets. #include<file.au3> DirCreate(@ScriptDir & "\testCopy") $SearchString = "488" $aFound = _FileListToArrayRec(@ScriptDir , "*" & $SearchString & "*||" , 1 , 1 , 0 , 2) _ArrayDisplay($aFound) For $i = 1 to ubound($aFound) - 1 filecopy($aFound[$i] , @ScriptDir & "\testCopy" , 1) Next Edited April 13, 2016 by iamtheky ericbartha 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
ShaSha Posted April 13, 2016 Author Share Posted April 13, 2016 59 minutes ago, ericbartha said: @alien4u, why not just use a wildcard so it ignores filenames altogether? Generally speaking, part numbers are a unique identifier so it should not be an issue. Instead of alien4u's code, try this replacement line If $file = $FileNameArray[$i] & ".*" Then Your updated script would now be: expandcollapse popupOpt("TrayIconDebug", 1) $S_running = "find-copy-photos" ;name the script If WinExists($S_running) Then MsgBox(0, "AutoIt", "The script to find and copy photos is already running") Exit EndIf AutoItWinSetTitle($S_running) $FileName = FileOpenDialog("Select the file that contains the list of photos to find & copy", "C:\temp\", "Text File (*.txt)") If @error Then Exit $FileNameArray = StringSplit(FileRead($FileName), @CRLF, 1) $PhotoFolder = FileSelectFolder("Select the top level folder that contains the photos.", "") If @error Then Exit $search = FileFindFirstFile($PhotoFolder & "\*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop For $i = 1 To $FileNameArray[0] If $file = $FileNameArray[$i] & ".*" Then FileCopy($PhotoFolder & "\" & $file, @DesktopDir & "\output\", 8) $FileNameArray[$i] = "" EndIf Next WEnd For $i = 1 To $FileNameArray[0] If $FileNameArray[$i] <> "" Then InputBox("Error", "Could not find:", $FileNameArray[$i]) If @error = 1 Then Exit EndIf Next Run("explorer.exe " & @DesktopDir & "\output\") @ShaSha, let me know if this works for you! I tried this and I couldn't get it to find any files Link to comment Share on other sites More sharing options...
iamtheky Posted April 13, 2016 Share Posted April 13, 2016 I might be biased, but I would use mine... ericbartha 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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