Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch file to import jpg

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I am not sure that this is the correct forum to post, but I could not find a closer forum. Please if this is not the correct forum could you point me in the right direction?

I have a .bat file

that goes out to one of my network drives and looks for all the .jpg files in a specified folder. This folde4r might contain multiple folders within what I get at the end is a text file with the location for each .jpg file
for example
c:\drawings\one\drw1.jpg
c:\drawings\one\drw2.jpg
c:\drawings\two\fld1.jpg, etc.
up to this point everything works well.
I am trying to accomplish two more things. I was given a file with about 2500 drawings all in different places
I would like to bring all these drawings to a specific folder

Here is the code that I am using
Code:
cd d:\
cd d:\drawings
erase c:\drawings\drawings.txt
dir d:\drawings\*.dwg /s /b  < c:\drawings\drawings.txt

any pointers are much appreciated thanks!!!
 
you would need to:

+ consume the drawings.txt file
+ read each line
+ for each file describe in each line, call a copy/move to your destination


Dim....
strSourceFile = "c:\drawings\drawings.txt"
strSourceFld = "c:\drawings\"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(strSourceFile) Then
Wscript.Echo "found " & strSourceFile
Set objTS = FSO.OpenTextFile(strSourceFile, 1, False)
Wscript.Echo "opened " & strSourceFile
Do While Not objTS.AtEndOfStream
strLine = ""
strLine = objTS.ReadLine
Wscript.Wcho "line = " & strLine
If strLine <> "" Then
If FSO.FileExists(strLine) Then
Wscript.Echo "found source file, " & strLine
'check if it is at the target? or just blindly copy?
'trap for errors?
FSO.CopyFile strLine, strSourceFld, True (this will fail i am sure as i think you need to specify the filename in the target as well as the folder? i can never remember?
Wscript.Echo "after attempt to copy, " & strLine
Else
Wscript.Echo "cant find source file, " & strLine
End If
End If
Loop
objTS.Close
Set objTS = Nothing
Else

End If
 
Thanks for the code, and please excuse my ignorance. is this VB code? or could I do this in a batch file?

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top