473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Copy jpg files from one folder to another

489 256MB
I've got a folder on my c: drive that has about 6 thousand photos. The photos have a file name of like 00239.jpg which matches a member number in my database. I want to move some of the photos to another folder on the c: drive. I have a table that is created with the photos I want to move. That table has the member number in it like 00239 How do I go about doing this in my program?
My mind has gone blank in how to do this.

Thanks for any help.
Jan 17 '13 #1

✓ answered by Stewart Ross

I'm puzzled by the Access crash too, but I notice that you appear to have incorrectly defined line 15 and wonder if this has something to do with it. Surely this line should be

Expand|Select|Wrap|Line Numbers
  1. Do While Not RSPhoto.EOF
rather than
Expand|Select|Wrap|Line Numbers
  1. Do While Not RSPhoto
-Stewart

7 3603
Rabbit
12,516 Expert Mod 8TB
This is not a code writing service but if you post the code you've tried along with a description of the problem, we can help guide you to a solution.

As a hint, you can use the FileCopy function in VBA.
Jan 17 '13 #2
CD Tom
489 256MB
I didn't mean to have someone write the code just point me the right direction which you did. However I've run into a funny problem here's the code
Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdExportApp_Click()
  2. On Error GoTo Err_CmdExportApp_Click
  3.     Dim db As Database
  4.     Dim RSPhoto As DAO.recordset
  5.     Set db = CurrentDb()
  6.  
  7.     vtable = "MbrsTOCSV"
  8.     apppathx = ("C:\Membership" + "\" + "App Data\" + "NewMBRS.csv")
  9.     DoCmd.TransferText acExportDelim, , vtable, apppathx, True
  10.  
  11.     strFolderName = "C:\Membership\App Data"
  12.     Kill strFolderName + "\" & "*.*"
  13.     strsql = "select * from CurrentPhotos"
  14.     Set RSPhoto = db.OpenRecordset(strsql)
  15.     Do While Not RSPhoto
  16.         vcp = RSPhoto("TPhoto")
  17.         vcp = vcp & ".JPG"
  18.         Sourcefile = ("C:\B4aExamples" + "\" + "TCGC JPG\" + "" & vcp & "")
  19.         Destinationfile = ("C:\Membership" + "\" + "Export Data\" + "" & vcp & "")
  20.         FileCopy Sourcefile, Destinationfile
  21.     RSPhoto.MoveNext
  22.     Loop
  23.  
  24.     Call GetZip
  25.  
  26. Exit_CmdExportApp_Click:
  27.     Exit Sub
  28.  
  29. Err_CmdExportApp_Click:
  30.     MsgBox Err.Description
  31.     Resume Exit_CmdExportApp_Click
  32.  
  33. End Sub
  34.  
the program runs fine for about four copies then access stops working and closes and restarts.
It will stop on the Do While Not RSPhoto no error messages access just stops working and restarts itself. Any ideas what could be causing this?
Jan 17 '13 #3
Rabbit
12,516 Expert Mod 8TB
That's weird that it would just stop without an error. Does it always stop on the fourth file? Maybe the filename is incorrect or something. Try stepping through the code to see which line it's stopping on.
Jan 17 '13 #4
Stewart Ross
2,545 Expert Mod 2GB
I'm puzzled by the Access crash too, but I notice that you appear to have incorrectly defined line 15 and wonder if this has something to do with it. Surely this line should be

Expand|Select|Wrap|Line Numbers
  1. Do While Not RSPhoto.EOF
rather than
Expand|Select|Wrap|Line Numbers
  1. Do While Not RSPhoto
-Stewart
Jan 17 '13 #5
zmbd
5,501 Expert Mod 4TB
That is strange... you might want to make sure you are starting with the first record before entering your loop.
Expand|Select|Wrap|Line Numbers
  1. RSPhoto.MoveFirst
Jan 17 '13 #6
CD Tom
489 256MB
Well that was it not having the .eof at the end made all the difference, don't know why I didn't notice that.
Thanks for all your help.
Jan 17 '13 #7
NeoPa
32,556 Expert Mod 16PB
Line #15 should probably be checking RSPhoto.EOF rather than RSPhoto itself Tom. That said, I don't follow why it would crash as you describe.

The only idea I have is that FileCopy may be asynchronous, but I seriously doubt that.

If the .EOF doesn't fix it then try adding DoEvents after line #21.

PS. Ooops. I must remember to refresh my pages when I'm busy with work :-(
I'll set the Best Answer for you.
Jan 18 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
11
by: Mike | last post by:
I want to be able to copy a directory of files (all .HTM files) from a network drive to a local drive on the machine c:\HTMFiles , How can i do that? I tried File.Copy(source, dest) but i need...
8
by: Chris Strobel | last post by:
I have 2 web servers where I need to write a PDF file and need to keep them in sync. In others words, If the Server1 is getting called to create the PDF, then it needs to copy the PDF to the other...
5
by: Roy | last post by:
My dll file is copied to the "%windir%\Microsoft.NET\Framework\{version}Temporary ASP.NET Files" folder when I compile my asp.net project. When I run the application. The dll under this folder is...
2
by: Xavier Valdés | last post by:
Hi all, I would like to copy FILES from the clipboard to a desired folder from VB.NET. I was able to copy files (with filedrop data format) to the clipboard but I don't know how to catch this...
2
by: Dámaso Velázquez Álvarez | last post by:
Hi, I need to copy files to a shared folder protected by username/password. I don't now autenticate me in the server to copy the files. Do I need to use the credentials to do it? How can i do...
2
by: 1388-2/HB | last post by:
On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This...
4
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new...
1
by: tienlx | last post by:
Hi all, I want to copy files to shared folder to another computer in Local area network. Although, Ba-hcm\Administrator have full access permission to that folder, but it always throws "Access...
0
by: studentintau | last post by:
I would thank you if you help me with the next subject : how do i copy all files from temporary internet files folder to another folder in drive D?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.