Skip to content

Batch file to create a relative list of files including subfolders

ZeroQI edited this page Jun 15, 2018 · 3 revisions

Relative path need to be in a filelist.tx file for restauration i use this to recreate from scanner filelist a fake library with 0 size files

@ECHO OFF REM 1 - if no filelist create filelist no folders REM 2 - if file there restore

IF EXIST filelist.txt goto RESTORE ECHO Press Enter to create listfile.txt containing all files relative path rundll32 user32.dll,MessageBeep -1 PAUSE SETLOCAL DisableDelayedExpansion SET "r=%__CD__%" type nul > filelist.txt FOR /R . %%F IN (*) DO ( SET "p=%%F" SETLOCAL EnableDelayedExpansion ECHO(!p:%r%=! ENDLOCAL ) >> filelist.txt ECHO [filelist.txt] created list rundll32 user32.dll,MessageBeep -1 GOTO EXIT

:RESTORE ECHO Press enter to create all dummy files from filelist.txt rundll32 user32.dll,MessageBeep -1 PAUSE

for /f "tokens=*" %%a in (filelist.txt) do ( IF NOT EXIST "%%~pa" mkdir "%%~pa" IF NOT EXIST "%%a" TYPE nul > "%%a" ) ECHO [filelist.txt] processed, blank files created rundll32 user32.dll,MessageBeep -1 GOTO EXIT

:EXIT ECHO Finished! PAUSE