Ho creato un semplice file batch per riorganizzare un insieme di file/cartelle. Funziona come dovrebbe, ma ho bisogno di stampare i risultati in un file di registro. Ho bisogno di produrre i risultati di ogni azione (creare una directory, spostare un file, rinominare/eliminare un file). Quando utilizzo il comando >>results.txt tutto ciò che riesco a ottenere è "1 file spostati". un sacco di volte. Ecco il codice:Stampa di risultati di file batch in un file di testo
FOR %%a IN (C:\scans\*.txt) DO CALL :read %%~na
TREE /f >> tree.txt
@GOTO :EOF
:read
@set FILE=%1
FOR /f "tokens=1,2" %%b IN (%FILE%.txt) DO CALL :makeDir %%b %%c
@GOTO :EOF
:makeDir
@set ACCOUNT=%1
@set CHECK=%2
mkdir %ACCOUNT%
CALL :move
@GOTO :EOF
:move
MOVE %FILE%.gif %ACCOUNT%
REN %ACCOUNT%\%FILE%.gif %CHECK%.gif
DEL %FILE%.txt
@GOTO :EOF
Come posso stampare sul file di registro (results.txt) ogni volta che viene eseguita un'azione?
EDIT: nuovo codice w/echi:
@echo off
FOR %%a IN (C:\scans\*.txt) DO CALL :read %%~na
TREE /f >> tree.txt
@GOTO :EOF
:read
@set FILE=%1
FOR /f "tokens=1,2" %%b IN (%FILE%.txt) DO CALL :makeDir %%b %%c
@GOTO :EOF
:makeDir
@set ACCOUNT=%1
@set CHECK=%2
mkdir %ACCOUNT%
@echo Made directory for %ACCOUNT% >> results.txt
CALL :move
@GOTO :EOF
:move
MOVE %FILE%.gif %ACCOUNT%
@echo %FILE% moved to %ACCOUNT%
REN %ACCOUNT%\%FILE%.gif %CHECK%.gif
@echo %ACCOUNT%\%FILE% renamed %CHECK% >> results.txt
DEL %FILE%.txt
@echo %FILE% deleted. >> results.txt
@GOTO :EOF
Si prova a attivare ECHO? –
in realtà è acceso, vero? dovrebbe echeggiare le invocazioni del comando move e ren. –