# Batch file to copy files



## Dilogoat (Nov 3, 2009)

I know there are solutions for this on this forum but I can't get any of them to work in my specific situation.

I have a program that cannot deal with ZIP files and I need to manually sort them out. What I can do is export a partial location for these ZIP files to a txt files so I have:

filelist.txt:
folder\file.zip
folder\file2.zip
...
filder\fileN.zip

What I want to be able to do is create a batch file that will read the location of these files and copy them to a folder. The files are located on a network share but they r are mapped in My Computer. I can modify to the txt file so it gives the full path as a UNC path or a hard path.

I've been trying to get it to work using a For In Do statement but I don't know if that's the best solution. Help would be greatly appreciated. Thanks.

Dilo.


----------



## Squashman (Apr 4, 2003)

If you need to replicate the folder structure you need to use xcopy or robocopy.
_Posted via Mobile Device_


----------



## PatrickMc (Jun 5, 2009)

You have a list of files in file "C:/filelist.txt". You want to copy each file in that list to folder "C:/NewFolder". Here is the batch script.


```
# Script CopyFromList.txt
var str listfile, list, folder, file
# Read file list from $listfile
cat $listfile > $list
# Go thru files one by one.
lex "1" $list > $file
while ($file <> "")
do
    # Copy this file to $folder.
    system -s "copy /Y " ("\""+$file+"\"") ("\""+$folder+"\"")
    # Get the next file
    lex "1" $list > $file
done
```
Script is in biterscripting ( http://www.biterscripting.com ) . Save the script in file "C:/Scripts/CopyFromList.txt", start biterscripting, run this command.


```
script "C:/Scripts/CopyFromList.txt" listfile("C:/filelist.txt") folder("C:/NewFolder")
```
It will copy all files listed in file "C:/filelist.txt" to folder "C:/NewFolder". You can change the values passed to arguments listfile() and folder() as necessary. The listfile() argument specifies the file that lists the files to be copied. The folder() argument specifies the folder to which files are to be copied. Simple enough.


----------

