:: by JaCk | Release 08/13/2017 | https://pastebin.com/QnyiHWWq | hide_meta.bat ---- Hides "Meta" files and directories Recursively.
:: -- "Meta" items are dictated by [func_process_meta_files]
:: Changelog
:: * 08/13/2017 - Changed filtering to findstr instead off for loop to speed up processing. Rewrote hide bunctions to support more funky dunky chark-ters
:: * 07/04/2017 - Fixed issue when for .actors directory not being processed, needs to be set as an extension
:: * 07/04/2017 - Fixed issue when entering Double Quoted entry into prompt
:: * 07/04/2017 - Changed hide output msg to be slightly cleaner -imo
:: * 07/04/2017 - Changed Prompted help msg to be slightly clearer
:: + 07/04/2017 - Added "extrathumbs" to the meta list
:: + 06/22/2017 - Intial Release
:::::::::::::::::::::::::::::::::::::::
::
:: JK'D Blame-Game Agreement 1.0b, "Finger-Pointer Edition", written by JaCk
::
::: No Warranty, No Guarantee, No Support, AS-IS
:::
::: USE AT YOUR OWN RISK
::: By sheer discretion and without notification, JaCk, retains the all rights, including exemptions, revocation of exemptions of this agreement!
:::
::: By Running this script or ANY portion of it's, this script's, contents, you agree to the following:
::: - that you fully understand what these commands, expressions, functions, and/or script(s) or portions of script(s) do
::: - that you take responsibility for any actions, damages, physical losses, intellectual property losses, and/or losses of ANY kind
::: - that you take responsibility for any revenue, profits, physical gains, intellectual property gains, and/or gains of ANY kind
::: - that you DO NOT seek compensation of any kind, monies or otherwise, in ANY FORM, from previous, current and future parties; not limited to:
::: -- anyone
::: -- everyone
::: -- it's author(s)
::: -- it's contributor(s)
::: -- any beneficiaries
::: -- users
::: -- distributors
::
:::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::
::
:: - Most Functions are sourced from JaCks "AVScraper.bat" which were sourced from "AVDumpme.bat"
:: -- On that note, this is not the most efficient script, if you do not like that write your own.
::
:: - Concepts sourced from a recollection (JaCk's brain dump) of
:: -- methods found stackexchange site(s) by various users customized with JaCk's taste
:: :: ::
:::::::::::::::::::::::::::::::::::::::
@echo off && setlocal EnableDelayedExpansion
rem Assigning Script Params to a variable
set "params_main_script=%*"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: ::::::
:::: User Settings/Input ::::
:::::: ::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
rem Hardcoded Path - bypassed only by passing in a parameter, default is NotSet
set "var_process_dir="
rem UTF8 support
rem Sets the console to be able to process utf8 character sets
rem Disable if you encounter weird problems
rem - Default: true
rem - Boolean: Enable set to any of the following [yes/true/1]
rem - Boolean: Disable set to any of the following [no/false/0]
set "_flag_utf8_support=true"
rem Hide any gif that matches everything except extension
set "hm_filer_name_matches_gif=true"
rem Hide File/Directory filters -- file/folder endings
set "hm_filer_name_ending=meta\> thumb\> thumbnail\> thumbnails\> extrafanart\> extrathumbs\> screenshots\> screenshot\> landscape\> backdrop\> clearart\> poster\> folder\> banner\> fanart\> disc\> logo\> palette\>"
rem Hide File/Directory filters --- Global match -- CAUTION - filters out when matched anywhere in dirtree/filename
set "hm_filer_name_wany=archos"
rem Hide File/Directory filters --- Extension
set "hm_filer_name_ext=.json\> .nfo\> .actors\> .description\> .xml\>"
rem filter exclusions
set "hm_filter_ignore_items=.\-.Manga. .\-.Sound. Relation. .\\meta\\."
:::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: -~-~-~-~-~-~-~-~-~-~-~-~-~- ### -~-~-~-~-~-~-~-~-~-~-~-~-~- ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: ::::::
:::: Doo-Daads-Whatnots ::::
:::: Errochecking-Prompts-Misc ::::
:::::: ::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
rem Process Booleans
call :func_set_flag_booleans
rem UTF8 Support
if defined _flag_utf8_support (
call :func_char_encode_init
)
rem When Params are provided, ass-u-me that it is a Comma/QuotedSpaced/Semi-Colon separated list.
rem Even a "list" containing 1 item
rem Does not matter if items at quoted or not
if defined params_main_script (
set "var_process_dir=!params_main_script!"
)
rem this help is only printed when the script is run without parameters
if not defined var_process_dir (
echo/&echo/&echo/&echo/&echo/&echo/&echo/&echo/
echo/ Info: %~n0 Usage:
echo/ %~nx0 [Base Directory]
echo/
echo/ Notes:
echo/ ~ Quotes are optional
echo/ ~ Prompted input or passing parameters work the same way
echo/ ~ Directory Lists are accepted
echo/ ~ Windows environment variables also ok
echo/
echo/ Examples:
echo/ %~n0 C:\My Media\My Sub Dir
echo/ %~nx0 "C:\My Media\My Sub Dir","M:\My Personal Media\Home Videos",'S:\Hidden\Tr0n Spotting'
echo/ %~nx0 %Userprofile%\Videos
echo/
)
rem ask user input when parameters are missing
if not defined var_process_dir (
echo/&echo/
set "input=!cd!"
echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
echo/
echo/ Input: Enter Base Directory or
echo/ a list of Directories to process
echo/
echo/ [Default: !input!]
echo/
echo/ -~-~- -~-~-~-~-~-~-~- -~-~-
set /p "input=Input > "
echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
set "var_process_dir=!input!"
set "input="
)
rem Process the input
rem when surrounded by doublequotes, strip them as they are added in the next loop
if defined var_process_dir if "!var_process_dir:~0,1!!var_process_dir:~-1,1!" equ """" (
set "var_process_dir=!var_process_dir:~1,-1!"
)
rem append gif to the exlusion list as needed
if defined hm_filer_name_matches_gif set hm_filter_ignore_items=.gif$ !hm_filter_ignore_items!
:: rem Converting single quotes to double quotes
:: rem Stripping double sets of double quotes to a single set
:: rem Converting semi-colons to commas
:: REM set "var_process_dir=!var_process_dir:'="!"
:: REM set "var_process_dir=!var_process_dir:""="!"
:: REM set "var_process_dir=!var_process_dir:""="!"
:: REM set "var_process_dir=!var_process_dir:;=,!"
rem Converts commas to Quoted Spaces and recurses through the list
if defined var_process_dir (
for %%a in ("!var_process_dir:,= !") do (
call :func_process_meta_files "%%~a"
)
set "var_process_dir="
) else (
echo/ Info: No input recieved, exiting...
)
if defined hm_cntr_hide (
echo/ Info: Total items hidden: !hm_cntr_hide!
set "hm_cntr_hide="
)
rem UTF8 Support
if defined _flag_utf8_support (
call :func_char_encode_deinit
set "_flag_utf8_support="
)
rem Scrub-de-dam
if defined params_main_script (
set "params_main_script="
)
:::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: -~-~-~-~-~-~-~-~-~-~-~-~-~- ### -~-~-~-~-~-~-~-~-~-~-~-~-~- ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: ::::::
:::: Bunctions ::::
:::::: ::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto :eof
:::::::::::::::: :::: :::::::::::::::::
rem International-love (utf8 only, otherwise, "get away from me you different, unclassified freak. Wow, 'non-standards' really crep me out")
rem Above is a joke, No, I'm not going to explain it || print Hello effing PC world && echo yes, pun intended
:func_char_encode_init
for /f "tokens=2 delims=:" %%c in ('chcp') do set "chcp_orig=%%c"
chcp 65001 2>nul 1>nul
if not !errorlevel! equ 0 (
echo/ ERROR: CHCP: UTF8 Support unavailible
set "_flag_chcp_errored=true"
)
goto :eof
:::::::::::::::::: :::::::::::::::::::
:::::::::::::::: :::: :::::::::::::::::
rem Well it was a phan vacation, time to get back to the grind... You.. You... You UTF8 you. *teehee* *giggle*
:func_char_encode_deinit
if not defined _flag_chcp_errored (
chcp !chcp_orig! 1>nul
) else (
set "_flag_chcp_errored="
)
goto :eof
:::::::::::::::::: :::::::::::::::::::
:::::::::::::::: :::: :::::::::::::::::
rem Hide any items recursively
rem Usage - call func_hide_item "C:\myfolder\My file.ext"
rem Usage - call func_hide_item "C:\myfolder\My Subfolder"
:func_hide_item
set "params_hide_item=%*"
set "params_hide_item=!params_hide_item:"=!"
rem Check item accessiblity, leave function on error
if not exist "!params_hide_item!" (
echo/ Error: Hide: Unable to locate "!params_hide_item!"
goto :eof
)
rem Check item hidden attribute, hide when needed
dir /b /o /a:h "!params_hide_item!" 2>nul 1>nul
if not !errorlevel! equ 0 (
echo/ Info: Hiding: "!params_hide_item!"
call attrib +H /S /D /L "!params_hide_item!"
)
set "params_hide_item="
goto :eof
:::::::::::::::::: :::::::::::::::::::
:::::::::::::::: :::: :::::::::::::::::
rem Hide any items recursively
rem Usage - call func_hide_item "C:\myfolder\My file.ext"
rem Usage - call func_hide_item "C:\myfolder\My Subfolder"
:func_hide_pitem
rem Check item accessiblity, leave function on error
if not exist "%~1" (
echo/ Error: Hide: Unable to locate "%~1"
goto :eof
)
rem Check item hidden attribute, hide when needed
dir /b /o /a:h "%~1" 2>nul 1>nul
if not !errorlevel! equ 0 (
echo/ Info: Hiding: "%~nx1"
call attrib +H /S /D /L "%~1"
set /a "hm_cntr_hide+=1"
)
goto :eof
:::::::::::::::::: :::::::::::::::::::
:::::::::::::::: :::: :::::::::::::::::
rem Please note, when modifying the block below
rem [%%~xz] is file extension
rem [%%~nz] is file/directory name
rem [%%~fz] is full file/directory name with path
rem These two lines look for a specific string in the file/directory name. When found [error state is 0] calls the hide function
rem echo "%%~nz" | findstr /i "archos" 2>nul 1>nul
rem if !errorlevel! equ 0 call :func_hide_item "%%~fz"
REM set "params_process_meta_files=%*"
REM set "params_process_meta_files=!params_process_meta_files:"=!"
REM echo/ Info: Hide: Prep: "!params_process_meta_files!"
REM 'dir /s /b /o:-n /a:-h "!params_process_meta_files!" 2^>nul ^| findstr /r /i /v ".gif$ .\-.Manga. .\-.Sound. Relation. .\\meta\\." 2^>nul'
:func_process_meta_files
if not exist "%~1" (
echo/ Error: Unable to access "%~1"
echo/ Error: Unable to process "%~1"
goto :eof
)
echo/
echo/ Info: Hide: Prep: "%~1"
for /f "tokens=1* delims=" %%z in (
'dir /s /b /o:-n /a:-h "%~1" 2^>nul ^| findstr /r /i /v "!hm_filter_ignore_items!" 2^>nul'
) do (
if defined hm_filer_name_matches_gif if exist "%%~dpnz.gif" call :func_hide_pitem "%%~dpnz.gif"
echo/"%%~nz" | findstr /r /i "!hm_filer_name_wany! !hm_filer_name_ending!" 2>nul 1>nul
if !errorlevel! equ 0 call :func_hide_pitem "%%~fz"
echo/"%%~xz" | findstr /r /i "!hm_filer_name_ext!" 2>nul 1>nul
if !errorlevel! equ 0 call :func_hide_pitem "%%~fz"
)
goto :eof
:::::::::::::::::: :::::::::::::::::::
:::::::::::::::: :::: :::::::::::::::::
rem For every variable that starts with [_flag_], check for true values and set/unset accordingly
:func_set_flag_booleans
for /f "tokens=1,* delims==" %%v in ('set _flag_') do (
set "_fvar_value=%%w"
if "!_fvar_value:~0,1!" equ "1" ( set "%%v=true"
) else if /i "!_fvar_value:~0,1!" equ "y" ( set "%%v=true"
) else if /i "!_fvar_value:~0,1!" equ "t" ( set "%%v=true"
) else set "%%v="
)
set "_fvar_value="
goto :eof
:::::::::::::::::: :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: :::::: :::::: :::::: :::::: ::::::
:::: :::: :::: ::::
:: -~-~-~-~-~-~-~ :: ### :: -~-~-~-~-~-~-~ ::
:::: :::: :::: ::::
:::::: :::::: :::::: :::::: :::::: ::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Comments
0 B
|👍
/👎