Results 1 to 6 of 6
  1. #1
    littleheart_Sony is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    8

    Batch Script to Move Files

    Could someone help me to run a batch file in access

    for example: Tiffs are available in some "X" folder and we need to move this into "Y"folder. how to run a batch file from Access2010 application.



    we have to operate from Access 2010

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by littleheart_Sony View Post
    Could someone help me to run a batch file in access

    for example: Tiffs are available in some "X" folder and we need to move this into "Y"folder. how to run a batch file from Access2010 application.

    we have to operate from Access 2010
    Since this question is not relevant to this thread, perhaps a new thread is in order.

    As for creating a batch file to copy directories, why bother when you can do it with VBA? Just reference the Filesystem Object for early binding. If you really want a script file, here is an example of copying a file using VBScript. It uses the .VBS extension.

    Code:
    Dim sourceFile
    Dim destinationFile
    Dim strDesFilName
    Dim strNow
    Dim aFSO
    strNow = Year(Date) & "_" & Month(Date) & "_" & Day(Date) & "_" & Hour(Now) & Minute(Now) & "_" & Second(Now)
    strDesFilName = "Inv_Copy_" & strNow & ".accdb"
    destinationFile = "C:\Inventory_Backup\" & strDesFilName
    sourceFile = "\\ServerName\Inventory\Inventory.accdb"
    Set aFSO = CreateObject("Scripting.FileSystemObject")
    aFSO.CopyFile sourceFile, destinationFile

  3. #3
    littleheart_Sony is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    8
    thanks for help,

    one more doubt is it possible if we put this in a form with command button once we run this we get the data from "X" folder to "Y" Folder.

    same which is happen in the bat file example : move : "c:/x/*example*.TIF" "C:/Y".

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The example in post #10 is Visual Basic. It can be used to create a VBScript (.vbs) file. This is very similar to creating a Batch (.bat) file and running the file. As I mentioned before, you can use code behind a form to do the same thing, without creating an external bat or vbs file.

    Access uses VBA or Visual Basic for Applications. VBA is not VB.

    I looked at the VB code in post #10 and I believe this will work behind a form in Access. You may need to change a couple of things, though.

    I would make a reference to Microsoft Scripting Runtime and use early binding of the File System Object Model (FSO). Then you could do stuff like the following (and more).

    Code:
    Dim fsoObject As New FileSystemObject
    Dim fsoFolder As Folder
    Dim fsoFile As File
    Dim strPath As String
        strPath = "C:\Test"
        Set fsoFolder = fsoObject.GetFolder(strPath)
            For Each fsoFile In fsoFolder.Files
                Debug.Print fsoFile.Name
            Next
    strPath = ""
    Set fsoFile = Nothing
    Set fsoFolder = Nothing
    Set fsoObject = Nothing

  5. #5
    littleheart_Sony is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    8
    i am not able to understand where this code use, i need one access database with the code for Move the data from one folder to another folder

    for example i have one folder with 50000 tif images out of this i have to move 30000 tifs in another folder and it takes lot of time i have the code in excel but i need this in access. please provide me the code in access database so that i can use this in access form by clicking with one button

    sorry for inconvience. can u please provide me the attachment of access for example if possible.

  6. #6
    littleheart_Sony is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    8
    any update on this issue

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-11-2014, 11:26 AM
  2. Replies: 10
    Last Post: 06-16-2014, 08:37 AM
  3. Replies: 1
    Last Post: 11-07-2013, 11:15 AM
  4. VB Script - Split Report PDF into mutiple files
    By rmikulas in forum Programming
    Replies: 2
    Last Post: 08-07-2012, 09:50 AM
  5. Open Accesss DB by batch script
    By micada in forum Access
    Replies: 0
    Last Post: 06-10-2008, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums