Batch file to copy files

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Dilogoat

Thread Starter
Joined
Nov 3, 2009
Messages
1
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

Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
If you need to replicate the folder structure you need to use xcopy or robocopy.
Posted via Mobile Device
 
Joined
Jun 5, 2009
Messages
14
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.


Code:
# 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.


Code:
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top