:: By JaCk | DevStable 07/26/2017 | https://pastebin.com/26ezgSpq | gifdir.bat -- uses ffmpeg_gifme.bat [ https://pastebin.com/JGL83SM8 ] to create gifs recursively through a directory tree @echo off && setlocal EnableDelayedExpansion EnableExtensions && (for /f "tokens=1 delims==" %%a in ('set gf_') do set "%%a=") 2>nul 1>nul @title %~nx0 -- Dr.GIF'd with Gifmei Haurdor :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: :::::: :::: Development Version :::: :::: USE AT YOUR OWN RISK :::: :::::: :::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::: :: user settings ::::::::::::::::::::::::::::::::::::::: rem :: Default: [undef] :: Type: dir location :: Accepted Values: [relative/absolute path] :: Description: -- hardcoded base directory set "gf_rpath=" ::::::::::::::::::::::::::::::::::::::: :: script setttings ::::::::::::::::::::::::::::::::::::::: rem :: Default: .avi .mkv :: Type: space delin list :: Accepted Values: [.ext1 .ext2] :: Description: -- extension list of video files set "gf_extensions=.avi .mkv .mpg .mpeg .webm .mp4 .ogm .mov .flv .bik" rem :: Default: true :: Type: Bi-State Boolean :: Accepted Values: [true/undef] :: Description: -- To dump files needed to be processed in the total counter :: Personal Note :: It helps as a sanity check, especially when doing large quantity of files/directories to have this enabled. set "gf_dump_pre_process_list=true" rem :: Default: true :: Type: Bi-State Boolean :: Accepted Values: [true/undef] :: Description: -- Set windows console encoding env to UTF8 to enable processing of non-latin characters. Disable if you encounter weird problems with naming. set "gf_utf8_support=true" ::::::::::::::::::::::::::::::::::::::: :: script magic-de-do-dads ::::::::::::::::::::::::::::::::::::::: :: UTF8 support -- Grab current encoding setting - when needed, change it to utf8 if defined gf_utf8_support ( for /f "tokens=2 delims=:" %%c in ('chcp') do set "gf_chcp_orig=%%c" if !gf_chcp_orig! neq 65001 ( chcp 65001 2>nul 1>nul || ( echo/ ERROR: CHCP: UTF8 Support unavailible chcp !gf_chcp_orig! 2>nul 1>nul set "gf_chcp_orig=" ) ) else ( set "gf_chcp_orig=" ) ) :: params if "%~1" neq "" ( set "gf_rpath=%*" ) :: popd like you've never popd before if !pushme_gf! geq 1 for /l %%P in (1,1,!pushme_gf!) do ( popd echo Info: pushme_gf: [%%P]: Stale Popds found... BAM - Blopd de-Popd-eded echo Info: pushme_gf: [%%P]: Current Directory: [!cd!] set /a "pushme_gf-=1" ) :: prompts if not defined gf_rpath ( set "gf_rpath=!cd!" echo/&echo/&echo/ echo/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ echo/_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_ echo/ echo/ ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- echo/ Input: Base Directory Path: echo/ echo/ Default ~^> !gf_rpath! echo/ ~-~ ~-~ ~-~ ~-~ ~-~ set /p "gf_rpath= ~>" echo/ ~-~ ~-~ ~-~ ~-~ ~-~ echo/-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- ) :: when double-quoted path, remove first and last double-quotes if defined gf_rpath if "!gf_rpath:~0,1!!gf_rpath:~-1,1!" equ """" set "gf_rpath=!gf_rpath:~1,-1!" :: f-u error-checking -- no purdy msgs, just f-u and gtfo if not defined gf_rpath goto :eof if not defined gf_extensions goto :eof ::::::::::::::::::::::::::::::::::::::: :: :: Setup Script :: ::::::::::::::::::::::::::::::::::::::: :: fixing extension list formatting -- make sure [no commas][space-delin][eol regex marker] for %%X in (!gf_extensions!) do set "gf_ext_li=%%X$ !gf_ext_li!" echo/&echo/&echo/&echo/&echo/&echo/ echo/ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ echo/-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ echo/ `'` `'` `'` `'` `'` `'` `'` `'` `'` `'` echo/ if defined gf_dump_pre_process_list ( echo/ -- GifDir: Info: Fluffing TollTalls and Dumpling filletnames ) else ( echo/ -- GifDir: Info: Tallying Gif'd'ed Counts ) echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ :: Total Possible files matching extension list :: for /f "tokens=1* delims=" %%A in ('dir /b /o:-n /a:-d /s "!gf_rpath!" ^| findstr /i "!gf_ext_li!" ^| find /c " "') do set "gf_total_matching_files=%%A" :: For roll call, getting missing Count Gif, He'll be write back set "gf_total_cnt=0" for /f "tokens=1* delims=" %%A in ('dir /b /o:-n /a:-d /s "!gf_rpath!" ^| findstr /i "!gf_ext_li!"') do ( set /a "gf_total_matching_files+=1" if not exist "%%~dpnA.gif" ( set /a "gf_total_cnt+=1" if defined gf_dump_pre_process_list echo/ [!gf_total_cnt!]: "%%~nxA" ) ) :: get string length of gf_total_cnt if !gf_total_cnt! geq 10 ( set "gf_P=!gf_total_cnt!#" for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do ( if "!gf_P:~%%P,1!" NEQ "" ( set /a "gf_zcount+=%%P" for /l %%q in (1,1,%%P) do set "gf_z=0!gf_z!" set "gf_P=!gf_P:~%%P!" ) ) ) else ( set "gf_zcount=1" set "gf_z=0" ) :: get string length of gf_total_matching_files if !gf_total_matching_files! geq 10 ( set "gf_P=!gf_total_matching_files!#" for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do ( if "!gf_P:~%%P,1!" NEQ "" ( set /a "gf_bmatchcount+=%%P" set "gf_P=!gf_P:~%%P!" for /l %%q in (1,1,%%P) do set "gf_mz=0!gf_mz!" ) ) ) else ( set "gf_bmatchcount=1" set "gf_mz=0" ) :: pretty colors.... em... I mean... Pretty numbers :: pad em first :: trim the fat if defined gf_mz if defined gf_total_cnt if defined gf_bmatchcount ( set "gf_scount_tl=!gf_mz:0= !!gf_total_cnt!" set "gf_scount_tl=!gf_scount_tl:~-%gf_bmatchcount%!" set "gf_smatchedf=!gf_mz!!gf_total_matching_files!" set "gf_smatchedf=!gf_smatchedf:~-%gf_bmatchcount%!" rem note - todo - finish making this purdy set "gf_empty_wshc=%gf_bmatchcount%" set "gf_empty_wspace= " set "gf_empty_wspace=!gf_empty_wspace:~%gf_empty_wshc%!" ) :: LFM -- Looking for more; totals :: WTBGif -- Gifs to be created by %~nx0 :: ICanHasGif -- Candidate Files for giffing by %~nx0 if not !gf_total_cnt! gtr 0 ( echo/ No gif-able files found ) echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ if defined gf_smatchedf if defined gf_scount_tl ( echo/ !gf_empty_wspace!~-~ # Gif Needed: !gf_scount_tl! ~-~ !gf_empty_wspace! echo/ !gf_empty_wspace!~-~ # Total Checked: !gf_smatchedf! ~-~ !gf_empty_wspace! ) else ( echo/ !gf_empty_wspace!~-~ Creating [!gf_smatchedf!] Gifs ~-~ !gf_empty_wspace! ) echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ echo/ echo/ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ echo/-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ echo/ `'` `'` `'` `'` `'` `'` `'` `'` `'` `'` echo/ if not !gf_total_cnt! gtr 0 goto :eof ::::::::::::::::::::::::::::::::::::::: :: :: Main :: ::::::::::::::::::::::::::::::::::::::: :: run it echo/ echo/ -- GifDir: Info: Main: [!date:~0,3! !time:~0,-6!]: Find em n gif-em echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ for /f "tokens=1* delims=" %%A in ('dir /b /o:-n /a:-d /s "!gf_rpath!" ^| findstr /i "!gf_ext_li!"') do ( if "!cd!\" neq "%%~dpA" ( popd set /a "pushme_gf-=1" pushd "%%~dpA" set /a "pushme_gf+=1" set "gf_dpush_msg=true" ) if exist "%%~nxA" if not exist "%%~nA.gif" ( set /a "gf_current_cnt+=1" set /a "gf_count_perc=!gf_current_cnt!00 / !gf_total_cnt!" set "gf_count_perc=!gf_count_perc!%%" set "gf_zcurrent_cnt=!gf_z!!gf_current_cnt!" set "gf_zcurrent_cnt=!gf_zcurrent_cnt:~-%gf_zcount%!" echo/ if defined gf_dpush_msg ( echo/ echo/ -- GifDir: Pushd Dir: "%%~dpA" set "gf_dpush_msg=" ) echo/ -- GifDir[!gf_count_perc!] !time:~0,-6!: File: !gf_zcurrent_cnt!/!gf_total_cnt! ~ "%%~nxA" call ffmpeg_gifme.bat "%%~nxA" "%%~nA.gif" "%%~nA.palette.png" if exist "%%~nA.gif" call attrib +H /S /D /L "%%~nA.gif" if exist "%%~nA.palette.png" call attrib +H /S /D /L "%%~nA.palette.png" ) ) ::::::::::::::::::::::::::::::::::::::: :: :: Destroy env changes made by me :: ::::::::::::::::::::::::::::::::::::::: :: Last minute popd-ing (when you gotta go, you go), setting up blanks (better than shooting em), and ending any local relationships (its not you, its me) if defined pushme_gf for /l %%p in (1,1,!pushme_gf!) do ( call popd && set /a "pushme_gf-=1" ) if !pushme_gf! leq 0 set "pushme_gf= if defined gf_chcp_orig chcp !gf_chcp_orig! 1>nul (for /f "tokens=1 delims==" %%a in ('set gf_') do set "%%a=") 2>nul 1>nul endlocal