How can I recursively move *.jpg files from a memory card to a specified directory?
I have searched the internet for days and not found a way to do this.
Thanks,
10 3329
How can I recursively move *.jpg files from a memory card to a specified directory?
I have searched the internet for days and not found a way to do this.
Thanks,
well, it depends of the version of VB you're using, but in most cases, something like this will help to move the file: - My.Computer.FileSystem.MoveFile("D:\mypic.jpg", "C:\path\mypic.jpg")
if you want to overwrite the file without asking you, you can turn off the dialogs, its an optional parameter of MoveFile.
I think using a FOR or a DO, and some time functions you can set when the files will be moved.
Remember that using smart file names can be helpful, e.g. - dim i as long
-
for i = 1 to 30
-
My.Computer.FileSystem.MoveFile("D:\mypic" & i & ".jpg", "C:\path\mypic" & i & ".jpg")
-
next
-
this way you can move mypic1, mypic2, mypic3 ... mypic30 quite easy.
otherwise, using DIR or FOR EACH might help you moving a complete directory.
HTH
VBA. -
Sub Test()
-
Dim source_path As String, target_path As String
-
-
source_path = "C:\Documents and Settings\WinblowsME\Desktop\Images"
-
target_path = "C:\Documents and Settings\WinblowsME\Desktop\Backup\"
-
-
Call Copy_Files(source_path, target_path, "*.jpg")
-
Call Copy_Files(source_path, target_path, "*.gif")
-
Call Copy_Files(source_path, target_path, "*.bmp")
-
End Sub
-
-
Private Sub Copy_Files(source_path As String, target_path As String, file_type As String)
-
Dim regex As Object, file_name As String
-
-
Set regex = CreateObject("VBScript.RegExp")
-
-
regex.Pattern = "\\*$"
-
source_path = regex.Replace(source_path, "\")
-
target_path = regex.Replace(target_path, "\")
-
-
file_name = Dir(source_path & file_type, vbDirectory)
-
-
Do While file_name <> ""
-
Call FileCopy(source_path & file_name, target_path & file_name)
-
-
file_name = Dir
-
Loop
-
End Sub
-
MS-DOS - copy "source_dir\*.jpg" "target_dir"
By "recursively", do you mean that you want to work your way down through the directory tree and copy all the images you find in there?
Yes,
I want to gather the .jpg buried about 2 directories down.
Search all the subdirectories.
Thanks,
I've got some code to do a recursive scan of subdirectories. I'll try to dig it out when I can. Might not be until tonight, though (it's about 10:30 now, Sydney time).
How would I use this in VB.net ?
Forgot to dig out my code. But the basic logic is quite simple. It's a recursive routine to handle each folder. Something along these lines. I recommend using FileSystemObject, but exactly how you access the files and folders is your choice, really. - Sub ProcessFolder(ByVal Fld As String)
-
For each file F in folder Fld
-
ProcessFile F
-
Next
-
For each subfolder S in folder Fld
-
ProcessFolder S
-
Next
-
End Sub
-
-
-
Sub ProcessFile(ByVal FileName As String)
-
Do whatever it is you want with file FileName
-
End Sub
Note I've just indicated we're passing the folder and file names here, as strings. But you could pass actual Folder or File objects.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ruby Tuesday |
last post by:
Is there a fast way to read files/directory recursively?
Instead of inspecting each file(s)/dir(s), is there a way to know that its a
file or a directory from its hidden attribut both for windows...
|
by: Antonio Lopez Arredondo |
last post by:
hi all !!!
I need to copy a folder and its subfolders to another location; which class
should I use ?
could only find the System.IO.Directory.MOVE but don't know how to COPY.
thanks in...
|
by: melo |
last post by:
Hello,
I've been struggling with a function(s) to recursively set all folders and
files to NOT read-only. So, I thought I'd post this message.
What I need to do is: given a starting path, I...
|
by: rbt |
last post by:
What is the most efficient way to recursively remove files and directories?
Currently, I'm using os.walk() to unlink any files present, then I call
os.walk() again with the topdown=False option...
|
by: Kamen TOMOV |
last post by:
Hi,
Is uploading recursively directories to a web server possible with
JavaScript?
I mean is it possible read a directory recursively and dynamically
construct <input type="file"> with value...
|
by: Zytan |
last post by:
You can download them here:
http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx
This snippet seems wrong:
Visual C# 2005 Code Snippets -filesystem -Search a Directory for
Files Recursively
...
|
by: pamela fluente |
last post by:
What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?
Is there any simple function in the framework to do that?
...
|
by: bhumikas |
last post by:
Hi all,
I need a help in perl script.The basic idea is,it must have command line arguments for the user flexibility.the files are in the format as shown below.
MainFolder
Directory
...
|
by: Jeff Schwab |
last post by:
I need to move a directory tree (~9GB) from one machine to another on
the same LAN. What's the best (briefest and most portable) way to do
this in Python?
I see that urllib has some support for...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |