Results 1 to 15 of 15

Thread: find jpg files

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    find jpg files

    I want to find all jpg files on a hard drive more than 10k.
    then move/copy them to a new folder on another drive

    Thank you

    Kind Regards

    John

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: find jpg files

    You can always install an utility called Everything from voidtools.com so you can search for all *.jpg file on your disks really fast.

    Then just copy/paste everything found to your new drive I guess.

    cheers,
    </wqw>

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by wqweto View Post
    You can always install an utility called Everything from voidtools.com so you can search for all *.jpg file on your disks really fast.

    Then just copy/paste everything found to your new drive I guess.

    cheers,
    </wqw>
    Thank you for getting back to me and giving me that link

    I have downloaded it and installed YES it does list al my jpg files all okay
    BUT it does not sort files abov 10k also make a folder on another drive then move them
    That is why I wanted a vb or batch file to do it.
    Many thanks anyway
    Regards
    John

  4. #4
    Addicted Member
    Join Date
    Jan 2013
    Posts
    144

    Re: find jpg files

    Hi,

    Here's a recursive file search project the does exactly what you need.
    The code has no error trapping at all so make sure that the files/folders do exist and all.

    Hope that helps

    Code:
    Imports System.IO
    
    Public Class Form1
        Dim Source As String = "C:\Pictures"
        Dim Target As String = "D:\Pictures"
        Dim Ext As String = ".jpg"
        Dim Siz As Integer = 10000
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Search(Source)
    End Sub
    
    Private Sub Search(Folder As String)
            For Each File In Directory.GetFiles(Folder)
                Dim This As New FileInfo(File)
                If This.Length > Siz And This.Extension = Ext Then
                    This.CopyTo(Target & "\" & This.Name)
                End If
            Next
            For Each SubFolder In Directory.GetDirectories(Folder)
                Search(SubFolder)
            Next
        End Sub
    End Class

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by cPubis View Post
    Hi,

    Here's a recursive file search project the does exactly what you need.
    The code has no error trapping at all so make sure that the files/folders do exist and all.

    Hope that helps

    Code:
    Imports System.IO
    
    Public Class Form1
        Dim Source As String = "C:\Pictures"
        Dim Target As String = "D:\Pictures"
        Dim Ext As String = ".jpg"
        Dim Siz As Integer = 10000
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Search(Source)
    End Sub
    
    Private Sub Search(Folder As String)
            For Each File In Directory.GetFiles(Folder)
                Dim This As New FileInfo(File)
                If This.Length > Siz And This.Extension = Ext Then
                    This.CopyTo(Target & "\" & This.Name)
                End If
            Next
            For Each SubFolder In Directory.GetDirectories(Folder)
                Search(SubFolder)
            Next
        End Sub
    End Class
    Thank you for getting back to me.

    I presume this line
    Dim Source As String = "C:\Pictures"

    I can change to

    Dim Source As String = "C:"

    If i want it to search ALL the hard drive

    Thank you for your trouble with me

  6. #6
    Addicted Member
    Join Date
    Jan 2013
    Posts
    144

    Re: find jpg files

    Happy to help dear. And yes, you can modify the code the way you like; the source/target folder locations, the file extension, the file size. I put them all in the beginning of the code.

    PS: if you believe that your issue is resolved, please mark the thread Resolved. Thanks.

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: find jpg files

    Quote Originally Posted by build View Post
    Thank you for getting back to me.

    I presume this line
    Dim Source As String = "C:\Pictures"

    I can change to

    Dim Source As String = "C:"

    If i want it to search ALL the hard drive

    Thank you for your trouble with me
    C: will not work but C:\ will.

    If you do that you'll need to add some Try-Catch blocks.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by dbasnett View Post
    C: will not work but C:\ will.

    If you do that you'll need to add some Try-Catch blocks.

    Sorry I do not know what you are talking about,"Try-Catch blocks" please can you explain

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by cPubis View Post
    Hi,

    Here's a recursive file search project the does exactly what you need.
    The code has no error trapping at all so make sure that the files/folders do exist and all.

    Hope that helps

    Code:
    Imports System.IO
    
    Public Class Form1
        Dim Source As String = "C:\Pictures"
        Dim Target As String = "D:\Pictures"
        Dim Ext As String = ".jpg"
        Dim Siz As Integer = 10000
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Search(Source)
    End Sub
    
    Private Sub Search(Folder As String)
            For Each File In Directory.GetFiles(Folder)
                Dim This As New FileInfo(File)
                If This.Length > Siz And This.Extension = Ext Then
                    This.CopyTo(Target & "\" & This.Name)
                End If
            Next
            For Each SubFolder In Directory.GetDirectories(Folder)
                Search(SubFolder)
            Next
        End Sub
    End Class
    I have just ran this code and sorry to say this whatI get

    "C:\Windows\system32>Public Class Form1
    'Public' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Windows\system32> Dim Source As String = "C:\Pictures"
    'Dim' is not recognized as an internal or external command,
    operable program or batch file.

    I have not posted ALL the faults BUTthey are all the same as above

    PLease help

    THank you

  10. #10
    Addicted Member
    Join Date
    Jan 2013
    Posts
    144

    Re: find jpg files

    Quote Originally Posted by build View Post
    I have just ran this code and sorry to say this whatI get

    "C:\Windows\system32>Public Class Form1
    'Public' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Windows\system32> Dim Source As String = "C:\Pictures"
    'Dim' is not recognized as an internal or external command,
    operable program or batch file.

    I have not posted ALL the faults BUTthey are all the same as above

    PLease help

    THank you
    Did you copy and paste the code into a command line prompt window?!

  11. #11
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: find jpg files

    Seems like this thread needs to be moved, since the OP is not expecting raw VB.NET code that needs to be compiled. I'll ask the mods to move it to General PC.

    My suggestion would be to use RoboCopy. Here is a link to the command line parameters, which include the ability to specify a minimum file size to copy.

    https://docs.microsoft.com/en-us/win...mands/robocopy

    Sorry, I don't have the ability to write out the specific parameters you would use in this case for a simple "just copy and paste" solution. Good luck.

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by cPubis View Post
    Did you copy and paste the code into a command line prompt window?!

    Done two things

    1 ....Copyed it into note pad then saved as a bat file " jpgtest.bat" got that fault

    2.....Ran cmd as admin then pasted the script into it still got that fault

    Hope this helps to what I did

    Thank you

  13. #13
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: find jpg files

    The code you were provided was not "batch file code", but rather, Visual Basic code that needs to be added to an existing Visual Basic project, compiled to an .exe file, and then executed.

    Did you check out the link to the RoboCopy documentation I included a few posts up?

    Good luck.

  14. #14

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    7

    Re: find jpg files

    Quote Originally Posted by OptionBase1 View Post
    The code you were provided was not "batch file code", but rather, Visual Basic code that needs to be added to an existing Visual Basic project, compiled to an .exe file, and then executed.

    Did you check out the link to the RoboCopy documentation I included a few posts up?

    Good luck.
    Thank you for getting back to me
    Yes I did thank you BUT it seamed to be so complicated for what I wanted.
    To make your script work what do I need to do?
    get Visual Basic program or some thing
    Thank you for your time

  15. #15
    Addicted Member
    Join Date
    Jan 2013
    Posts
    144

    Re: find jpg files

    Hello John,

    Here's a batch code that does exactly what you need.
    Just copy it into note pad then save it as a bat file "jpgtest.bat" then execute it.
    You can modify the folder locations as you like.

    Code:
    @echo off
    setlocal enabledelayedexpansion
    for /R "c:\pictures" %%F in ("*.jpg") do (
    if %%~zF geq 10000 copy "%%~F" "d:\pictures")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width