Supportnet / Forum / BS-Sonstige
Batch Script string
Frage
HAllo allerseits, ich möchte eine Datei
215214_001.bat heist verschieben und dabei/anschließend die Datei umbenennen, dass _001 wegfällt und ich am ende nur noch 215214 habe.
Allerdings sind die ersten Zahlen nicht immer 6 Stellen lang. es könnte also auch 2458_001.bat heißen.
Hat einer eine Idee wie das funktionieren könnte?
Danke für eure Hilfe
Antwort 1 von Undertaker
Hi,
also wenn Du statt DOS die DOS-Emulation meinst, geht das bei Win 2000/XP ganz easy:
Gruß
Undertaker
also wenn Du statt DOS die DOS-Emulation meinst, geht das bei Win 2000/XP ganz easy:
SET source=C:\QuellverzeichnisSET dest=D:\ZielverzeichnisDIR /B %source%*_*.bat>dir.txt
FOR /F "tokens=1,2,3 delims=_." %%a IN (dir.txt) do MOVE %source%%%a_%%b.%%c %dest%%%a.%%c
DEL dir.txt
Gruß
Undertaker
Antwort 2 von Undertaker
Bäh, watt´n datt. Wieso ist das nun alles in einer Zeile...
also nochmal:
also nochmal:
SET source=C:\Quellverzeichnis
SET dest=D:\Zielverzeichnis
DIR /B %source%*_*.bat>dir.txt
FOR /F "tokens=1,2,3 delims=_." %%a IN (dir.txt) do MOVE %source%%%a_%%b.%%c %dest%%%a.%%c
DEL dir.txt
Antwort 3 von Undertaker
nu aber richtig:
Gruß
Undertaker
SET source=C:\Quellverzeichnis\SET dest=D:\Zielverzeichnis\DIR /B %source%*_*.bat>dir.txt
FOR /F "tokens=1,2,3 delims=_." %%a IN (dir.txt) do MOVE %source%%%a_%%b.%%c %dest%%%a.%%c
DEL dir.txt
Gruß
Undertaker
Antwort 4 von Undertaker
aber jetzt ;-)
SET source=C:\Quellverzeichnis\
SET dest=D:\Zielverzeichnis\
DIR /B %source%*_*.bat>dir.txt
FOR /F "tokens=1,2,3 delims=_." %%a IN (dir.txt) do MOVE %source%%%a_%%b.%%c %dest%%%a.%%c
DEL dir.txt
Antwort 5 von Butti
1000 Dank!