Backup a folder's tree structure. Then rebuilt the tree from
Posted: 04 Mar 2008 10:11
This script backups (as DOS commands), a folder's tree structure.
Then use the built script "Flat2Tree.cmd" to rebuild the folder's tree structure from all files in the root level.
Is that clear what I'm saying to explain ??
- Of course, it ignores files located in the root level.
- All files (from any sub folder, should have a different filename.
2 mode of use:
- Place this script in the root of folder's tree to backup and launch it.
- Drag and drop on this script any file in the root of folder's tree to backup.
Launch "Flat2Tree.cmd" to rebuilt the tree structure from flatten files.
"flatten files" means: all files of the folder's tree structure are in the root level.
Any comment will be appreciate.
Thanks.
Then use the built script "Flat2Tree.cmd" to rebuild the folder's tree structure from all files in the root level.
Is that clear what I'm saying to explain ??
- Of course, it ignores files located in the root level.
- All files (from any sub folder, should have a different filename.
2 mode of use:
- Place this script in the root of folder's tree to backup and launch it.
- Drag and drop on this script any file in the root of folder's tree to backup.
Launch "Flat2Tree.cmd" to rebuilt the tree structure from flatten files.
"flatten files" means: all files of the folder's tree structure are in the root level.
Any comment will be appreciate.
Thanks.
Code: Select all
@ECHO OFF
SETLOCAL
CD /D "%~DP1"
@SETLOCAL ENABLEDELAYEDEXPANSION
::--------------------- Calcul De La Taille Du Chemin Racine
IF /i "%~DP1"=="" (SET Racine=%~DP0) ELSE (SET Racine=%~DP1)
SET s=%Racine%
:LEN
SET /a L+=1
SET s=%s:~0,-1%
IF "%s%"=="" (GOTO:NEX1) ELSE GOTO:LEN
:NEX1
ECHO.--------------------------
ECHO.Collecte De L'Arboressence
ECHO.Patientez ...
ECHO.
:FLOG
SET z=Flat2Tree.cmd
TYPE NUL>"%z%"
(
ECHO.::[%Racine%]
ECHO.ECHO.^&COLOR 0C^&ECHO.*** ATTENTION
ECHO.PING -n 3 LocalHost ^>Nul ^& EXIT
FOR /f "Delims=*" %%f in ('DIR /b /ad /on /s') DO (
CD "%%f"
ECHO.
Call:FolC "%%~f"
FOR /f "Delims=" %%a in ('DIR /b /a-d /on *.*') DO (Call:FilC "%%f" "%%a")
)
)>>"%z%"
GOTO:FinN
:FolC ::----------------- Commande MC
SET s=%~1&ECHO.MD "!s:~%L%!"&GOTO:EOF
:FilC ::----------------- Commande MOVE
SET s=%~1
SET e=%~2
ECHO. MOVE /Y "!e!" "!s:~%L%!"&GOTO:EOF
:FinN
ECHO.END. BYE ..... &PING -n 3 LocalHost>Nul&EXIT