[Batch] Archiver le contenu de chaque sous-dossier
Fermé
-Baal-
Messages postés
1
Date d'inscription
mercredi 27 avril 2016
Statut
Membre
Dernière intervention
27 avril 2016
-
Modifié par -Baal- le 27/04/2016 à 15:56
barnabe0057 Messages postés 14439 Date d'inscription lundi 2 mars 2009 Statut Contributeur Dernière intervention 14 avril 2024 - 21 avril 2017 à 21:47
barnabe0057 Messages postés 14439 Date d'inscription lundi 2 mars 2009 Statut Contributeur Dernière intervention 14 avril 2024 - 21 avril 2017 à 21:47
A voir également:
- [Batch] Archiver le contenu de chaque sous-dossier
- Mettre un mot de passe sur un dossier - Guide
- Dossier appdata - Guide
- Word a trouvé du contenu illisible - Guide
- Fichier batch - Guide
- Dossier rar - Guide
1 réponse
barnabe0057
Messages postés
14439
Date d'inscription
lundi 2 mars 2009
Statut
Contributeur
Dernière intervention
14 avril 2024
4 905
21 avril 2017 à 21:47
21 avril 2017 à 21:47
Bonjour,
Essaie comme ça :
Essaie comme ça :
@echo off
Setlocal enableextensions enabledelayedexpansion
set source=C:\Test
if not exist "%source%" (goto :eof)
set liste=%source%\liste.txt
set archivename=%date:~0,2%-%date:~3,2%-%date:~6,4%.7z
set temp=%source%\temp
if exist "%temp%" (rmdir /S /Q "%temp%")
timeout /t 2 /nobreak
mkdir "%temp%"
cd %source%
for /f "tokens=*" %%A in ('dir "*.*" /ad /b') do (
set dossier=%%A
dir /b /a-d /on toto*.txt > %liste%
call :checklist
)
explorer /select,"%temp%"
rmdir /S /Q "%temp%"
Endlocal
exit
:checklist
for /f "tokens=*" %%I in ('type "%liste%"') do (set /a files+=1)
if !files! GTR 5 (call :archiver)
goto :eof
:archiver
set /a nb=!files!-5
set /a pos=1
for /f "usebackq tokens=*" %%Z in ("%liste%") do (
set fichier=%%Z
if !pos! NEQ !nb! (move "%source%\!dossier!\!fichier!" "%temp%")
set /a pos=!pos!+1
)
cd %source%\!dossier!
call :doublon
7za a -y -t7z !archivename! %temp%\
del /F /Q "%temp%\*.*"
goto :eof
:doublon
if exist "!archivename!" (set "archivename=!archivename!#" & goto :doublon)
goto :eof
rem