views:

249

answers:

2

Hi,

I have a folder with approx 10000 images, and I need to copy about 500 of them to another folder.

If I create a list of the files I want to copy, how could I copy the files the files?

Was thinking vbscript or is it possible thorough DOS commands such as Xcopy using switches?

Thanks,

+2  A: 

assuming that you had the list of files in a text file, here's a vbscript

Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
strDestination = objArgs(1)
Set objFile =objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfLine
    strLine = objFile.ReadLine
    objfs.CopyFile strLine,strDestination &"\"&strLine
Loop

save as myscript.vbs and on command line

C:\test>more file
test1.txt
test2.txt

c:\test> cscript //nologo myscript.vbs file c:\destination\directory

OR if you want batch

@echo off
for /F %%i in (file) do (  copy "%%i" c:\destination   )

if you want to move list of files according to some pattern, just do

c:\test> copy *pattern*.txt c:\destination
ghostdog74
+1  A: 

For a one-off on the command line, prepare a filenames.txt, one name per line. Then issue:

for /f %n in (filenames.txt) do copy "%n" "t:\arget\folder"

for VBScript, you can achieve the same thing using Scripting.FileSystemObject and it's close relatives (like the File and Folder objects), but in comparison this is more complicated. ghostdog74's answer shows one way.

Tomalak