|
|
|
|
Bonjour,
j'ai un petit soucis de batch. J'ai le fichier .txt ci dessous :
R‚pertoire de W:\IMBY5843\My Documents 17/07/2009 14:18 <REP> OutlookSoft R‚pertoire de W:\FRPS7596\My Documents 05/03/2009 12:55 <REP> OutlookSoft R‚pertoire de W:\zfrl3150\My Documents 28/07/2009 09:51 <REP> OutlookSoft
IMBY5843 17/07/2009 14:18 FRPS7596 05/03/2009 12:55 zfrl3150 28/07/2009 09:51
Configuration: Windows server 2003
Hello
$ type f1.txt Répertoire de W:\IMBY5843\My Documents 17/07/2009 14:18 <REP> OutlookSoft Répertoire de W:\FRPS7596\My Documents 05/03/2009 12:55 <REP> OutlookSoft Répertoire de W:\zfrl3150\My Documents 28/07/2009 09:51 <REP> OutlookSoft $ aa IMBY5843 17/07/2009 14:18 FRPS7596 05/03/2009 12:55 zfrl3150 28/07/2009 09:51 $ type aa.bat @echo off setlocal enableDelayedExpansion for /f "tokens=3,5,6" %%a in (f1.txt) do ( set x=%%a set x=!x:\= ! for /f "usebackq tokens=2" %%d in (`echo !x!`) do echo %%d %%b %%c ) |
Hello dubcek,
SetLocal enabledelayedexpansion
SetLocal enableextensions
SET file_user="C:\users.txt"
SET tmp="C:\tmp.txt"
SET last_date_used=c:\last_date_used.csv
Type NUL >%last_date_used%
Type NUL >%liste_users%
Type NUL >%tmp%
SET rep_tmp="My Documents"
SET rep_tmp=!rep_tmp:~1,-1!
FOR /F "tokens=1 delims=$" %%A IN ('type "%file_user%"') DO (
DIR "w:\%%A\!rep_tmp!\Outlooksoft.*" /N>%tmp%
FOR /F "tokens=1 delims= " %%d IN ('type "%tmp%" ^| FINDSTR "OutlookSoft"') DO (
echo.%%A;%%d>>%last_date_used%
)
)
Encore Merci ! |
On peut simplifier
$ type f1.txt
Répertoire de W:\IMBY5843\My Documents 17/07/2009 14:18 <REP> OutlookSoft
Répertoire de W:\FRPS7596\My Documents 05/03/2009 12:55 <REP> OutlookSoft
Répertoire de W:\zfrl3150\My Documents 28/07/2009 09:51 <REP> OutlookSoft
$ aa
IMBY5843 17/07/2009 14:18
FRPS7596 05/03/2009 12:55
zfrl3150 28/07/2009 09:51
$ type aa.bat
@echo off
for /f "tokens=4,7,8 delims=\ " %%a in ('type f1.txt') do echo %%a %%b %%c |