-
Jul 31st, 2022, 12:24 PM
#1
Thread Starter
New Member
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
-
Jul 31st, 2022, 01:07 PM
#2
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>
-
Jul 31st, 2022, 02:21 PM
#3
Thread Starter
New Member
Re: find jpg files
Originally Posted by wqweto
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
-
Jul 31st, 2022, 04:13 PM
#4
Addicted Member
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
-
Jul 31st, 2022, 05:41 PM
#5
Thread Starter
New Member
Re: find jpg files
Originally Posted by cPubis
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
-
Jul 31st, 2022, 06:01 PM
#6
Addicted Member
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.
-
Aug 1st, 2022, 11:49 AM
#7
Re: find jpg files
Originally Posted by build
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.
-
Aug 1st, 2022, 12:09 PM
#8
Thread Starter
New Member
Re: find jpg files
Originally Posted by dbasnett
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
-
Aug 1st, 2022, 12:53 PM
#9
Thread Starter
New Member
Re: find jpg files
Originally Posted by cPubis
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
-
Aug 1st, 2022, 01:03 PM
#10
Addicted Member
Re: find jpg files
Originally Posted by build
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?!
-
Aug 1st, 2022, 03:18 PM
#11
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.
-
Aug 2nd, 2022, 07:32 AM
#12
Thread Starter
New Member
Re: find jpg files
Originally Posted by cPubis
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
-
Aug 2nd, 2022, 07:08 PM
#13
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.
-
Aug 3rd, 2022, 03:59 AM
#14
Thread Starter
New Member
Re: find jpg files
Originally Posted by OptionBase1
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
-
Aug 3rd, 2022, 07:19 AM
#15
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|