另类的文件夹加密(批处理实现)
之前看到有网友把日本两人剧情片放在诸如“日本文化交流”、“英语四六级”等文件夹里,或者建很多个很深的文件夹,然后放到其中一个文件夹内,一般人看到就不会想翻的。闲来无事,就写了个批处理来实现。
此批处理可以实现每层新建指定个数的文件夹,然后每个文件夹里再递归新建相同个数的文件夹,一直达到指定的层数为止。
批处理代码如下:
@echo off ::MAXDIR为每层的文件夹个数,最大为10,既:0,1,2...9 set /p MAXDIR=请输入每位密码选择的个数(默认值5)(范围:1-10): if ""=="%MAXDIR%" set /a MAXDIR=5 if %MAXDIR% lss 1 goto :error if %MAXDIR% gtr 10 goto :error ::MAXDEEP为密码的位数 set /p MAXDEEP=请输入密码位数(默认值5): if ""=="%MAXDEEP%" set /a MAXDEEP=5 if %MAXDEEP% lss 1 goto :error set /a deep=1 set /a dirCount=0 set /a MAXDEEP=MAXDEEP+1 call :calcCount call :mdNew echo. echo 创建:%cd% echo 需要创建文件夹个数:%dirCount% echo 正在创建中,正耐心等待。。。 echo 按Ctrl+C可以中止程序 goto :circle :end echo 操作已完成 title 操作已完成 pause exit :circle if "0"=="%deep%" goto :end call :getMaxDirName ::得到当前目录内最大文件夹名 if "NoDir"=="%maxDirName%" goto :maxDirName_0 goto :maxDirName_1 :maxDirName_0 set /a maxDirName=0 goto :mdDirAndCd :maxDirName_1 set /a maxDirName=maxDirName+1 if "%MAXDIR%"=="%maxDirName%" goto:maxDeep :mdDirAndCd ::建立文件夹并进入 md %maxDirName% cd %maxDirName% set /a dirCount=dirCount-1 title 剩余-%dirCount% set /a deep=deep+1 if "%MAXDEEP%"=="%deep%" goto :maxDeep goto :circle :maxDeep rem echo>test.txt cd.. set /a deep=deep-1 goto :circle :getMaxDirName set maxDirName=NoDir for /l %%i in (9,-1,0) do if exist %%i set /a maxDirName=%%i & goto :eof goto :eof :mdNew if not exist 加密文件夹 md 加密文件夹 & cd 加密文件夹 & goto :eof for /l %%i in (0,1,9999) do if not exist 加密文件夹_%%i (md 加密文件夹_%%i & cd 加密文件夹_%%i & goto :eof) goto :eof :calcCount set /a dirCount=MAXDIR set /a temp=MAXDIR for /l %%i in (3,1,%MAXDEEP%) do set /a dirCount=dirCount+temp*MAXDIR & set /a temp=temp*MAXDIR goto :eof :error echo 输入有误! pause exit
截图如下:
用此批处理创建了个5层、每层5个文件夹的DEMO,里面有彩蛋哦,大家可以找找,DEMO下载链接:程序员寻找彩蛋
DEMO截图如下: