marcushb
Goto Top

Files anhand eines Textfiles kopieren - Dateinamen nur bedingt verfügbar - Wildcard copy

Hallo zusammen,

ich habe eine Textdatei mit RG Nummer und möchte die dazugehörigen PDF Rechnungen aus einem Archiv kopieren.

Die Textdatei sieht so aus:

12346
12347
12528
etc

Die PDFs lautet aber:

de_12346_140205.pdf
de_12347_140204.pdf
etc

Wie kann ich mit Wildcards die Files aus dem Verzeichnis kopieren ?

Hoffe jemand hat eine idee ..

DAnke & Gruß
Marcus

Content-Key: 228802

Url: https://administrator.de/contentid/228802

Printed on: April 23, 2024 at 18:04 o'clock

Member: LennyLinux
LennyLinux Feb 05, 2014 updated at 12:15:17 (UTC)
Goto Top
Unter verwendung welcher Sprache möchtest du dies tun?? VB.NET C.NET JAVA VBA VB ...

Grüße Lenny Linux
Member: marcushb
marcushb Feb 05, 2014 at 12:18:16 (UTC)
Goto Top
Hi,

Unter Windows entweder Batch oder VBScript.

Danke

Gruß
Marcus
Member: colinardo
Solution colinardo Feb 05, 2014, updated at Feb 14, 2014 at 12:44:50 (UTC)
Goto Top
Hallo Marcus,
Pfade entsprechend anpassen ...
back-to-topBatch:
@echo off
set "textdatei=C:\Temp\info.txt"  
for /f "usebackq delims=" %%a in ("%textdatei%") DO @(  
  copy "C:\temp\source\de_%%a_*.pdf" "C:\temp\target"  
)
back-to-topVBS:
Set fso = CreateObject("Scripting.Filesystemobject")  
textfile = "C:\temp\info.txt"  
sourcepath = "C:\temp\source"  
targetpath = "C:\temp\target"  
arrLines = Split(fso.OpenTextFile(textfile).ReadAll(),vbNewLine,-1,1)

For i = 0 To UBound(arrLines)
	line = Trim(arrLines(i)) 
	If line <> "" Then  
		On Error Resume Next
		fso.CopyFile sourcepath & "\de_" & line & "_*.pdf", targetpath & "\"  
	End If
Next
MsgBox "Fertig"  
Grüße Uwe
Member: marcushb
marcushb Feb 14, 2014 at 12:45:21 (UTC)
Goto Top
Hallo Uwe,

vielen Dank nochmal an dieser Stelle für die Hilfe ! Hat alles wunderbar geklappt !

Gruß
Marcus