Jump to content

Copying multiple files in a list, from one folder to another


Recommended Posts

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

Find Folder with Images.JPG

Find Part Number List.JPG

script screenshot.JPG

Link to comment
Share on other sites

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

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 =/

 

Error Could Not Find.JPG

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

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

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

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 by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

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:

Opt("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

I might be biased, but I would use mine...

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...