Results 1 to 7 of 7

Thread: Batch File to Move or Copy Files

  1. #1
    Join Date
    Aug 2006
    Posts
    168

    Batch File to Move or Copy Files

    I want to create the Batch File to move executable files from a source directory and its sub-folders to another location. Also I want to create the Batch File to copy certain files in the specific location. Does anyone have an idea how to create it? Please help me as soon as possible.
    "All gave some, some gave all."

  2. #2
    Join Date
    May 2008
    Posts
    4,570

    Re: Batch File to Move or Copy Files

    You can try the following batch code to Move the files :
    @echo off
    for /F "delims=" %%i in (files.txt) do (
    echo %%i
    move "%%i" c:\hello
    )
    Space is a default delimiter. The delims parameter fixes that (here there are no default delimiters other than a newline). You'll also need double quotes around your variable name on the move line. Hope that you were looking for the same.

  3. #3
    Join Date
    May 2008
    Posts
    4,831

    Re: Batch File to Move or Copy Files

    Try the batch command that I mentioned below which can be useful to copy the files :

    set path=c:\WINDOWS\system32;
    echo Copying started at %date% %time%>>_date_.txt
    xcopy E:\backup \\SERVER\BACKUP\others /s /a /d
    echo Copying finished at %date% %time%>>_date_.txt
    echo Completed Successfully at %date% %time%>>_date_.txt

  4. #4
    Join Date
    Apr 2008
    Posts
    4,088

    Re: Batch File to Move or Copy Files

    I think that the Batch Code mentioned by the "Macarenas" should work. I have not tried to check that personally, but seeing that I guess it should work properly. If you are not able to then just use
    Xcopy directory [destination-directory]
    and then turn this into a .BAT file
    You can find the more information regarding your query at Batch file to copy a file from the local drive to a computer on lan?

  5. #5
    Join Date
    Jan 2008
    Posts
    3,755

    Re: Batch File to Move or Copy Files

    I have used the following script to copy file quickly from source to destination. This script can work on Windows XP, 2003 or the lower version. This script accept the two command line argument and the syntax for that is :
    mycopy.bat {source} {destination}
    Where,
    mycopy.bat is script that copies files and directories including subdirectories using Windows xcopy program.
    source is used to specify the location and names of the file/directory you want to copy.
    destination is used to specify the destination of the files you want to copy.

  6. #6
    Join Date
    May 2008
    Posts
    3,316

    Re: Batch File to Move or Copy Files

    The source code of the mycopy.bat should be as follows :
    @rem BATCH FILE
    @echo off
    if "%1" == "" goto error1
    if "%2" == "" goto error2
    @rem * Copy from source to destination including subdirs and hidden
    @rem * File
    xcopy "%1" "%2" /S /E /H
    goto endofprogram
    :error1
    echo You must provide source
    echo Syntax:
    echo %0 source destination
    goto endofprogram
    :error2
    echo You must provide destination
    echo Syntax:
    echo %0 source destination
    goto endofprogram
    :endofprogram

  7. #7
    Join Date
    Dec 2009
    Posts
    23

    Re: Batch File to Move or Copy Files

    I want to create the Batch File to move executable files from a source directory and its sub-folders to another location.

    Code:
    # Script MoveExe.txt
    var str source, destination, list, file
    lf -r -n -g "*.exe" $source > $list
    while ($list <> "")
    do
        lex "1" $list > $file
        system move ("\""+$file+"\"") ("\""+$destination+"\"")
    done


    Script is in biterscripting. Save the script in file "C:/Scripts/MoveExe.txt". To call the script, type this command into biterscripting GUI.

    Code:
    script "MoveExe.txt" source("C:/testfolder1") destination("C:/testfolder2")

    Will move all .exe files from the source directory "C:/testfolder1" and its sub-folders (see the -r flag) to the destination folder of 'C:/testfolder2".

Similar Threads

  1. Cannot delete/copy/move .MOV files
    By Beckinsale in forum Vista Help
    Replies: 7
    Last Post: 21-03-2012, 11:19 AM
  2. batch file to copy file to another place
    By bomblast in forum Windows Software
    Replies: 1
    Last Post: 03-11-2011, 12:53 AM
  3. Batch file to copy ip
    By zaharkl in forum Technology & Internet
    Replies: 1
    Last Post: 21-04-2011, 10:50 AM
  4. Can't Copy/Move Ext HD Files to iMac
    By Joe Michaels in forum Hardware Peripherals
    Replies: 1
    Last Post: 25-08-2009, 11:11 AM
  5. Replies: 3
    Last Post: 12-03-2009, 12:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,388,543.82340 seconds with 17 queries