https://www.52pojie.cn/thread-1550652-1-1.html
定时关机.bat
::定时关机脚本
::Author:Tony Chang
::2016.10.18
::原创代码,转载请注明出处
@echo off
mode con lines=25
setlocal enabledelayedexpansion
title 定时关机
color 1f
cls
set "timeGoal= 21:15"
echo.
echo.
echo.
echo 时间使用24小时制(如2:15),默认关机时间为:%timeGoal%
echo.
echo 取消已有关机计划 按N;
echo.
echo.当前时间 %time:~0,5%
echo.
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
echo.
set /p "timeGoal= 请输入关机时间:"
echo.
if %timeGoal%==N goto cancel
if %timeGoal%==n goto cancel
set tmp=%timeGoal%
::将"号替换成空格
set /a num = 0
set "tmp=%tmp:"= %"
:next
if not "%tmp:~0,1%"==":" (
set /a num+=1
set "tmp=%tmp:~1%"
goto next
)
set /a hourNow = %time:~0,2%
set /a minuteNow = %time:~3,2%
set /a secNow = %time:~6,2%
set /a hourGoal =!timeGoal:~0,%num%!
set /a num+=1
set /a minuteGoal = !timeGoal:~%num%,2!
set /a "diffT = hourGoal - hourNow"
::diffT<0;
if %diffT% lss 0 (
echo 将设置为明天%timeGoal%关机
set /a "diffT = diffT + 24"
)
set /a "diffT = diffT*3600+(minuteGoal-minuteNow)*60 - secNow"
if %diffT% lss 0 (
echo 将设置为明天%timeGoal%关机
set /a "diffT = diffT + 86400"
)
shutdown -s -t %diffT%
echo 已设置%timeGoal%的关机计划
goto exit
:cancel
shutdown -a
echo 已取消当前设定
goto exit
:exit
echo.
echo 3秒后退出……
choice /t 3 /d y /n >nul
当前子目录文件移动到目录
for /f "tokens=* delims=" %%i in ('dir /b /a-d /s "*"') do (move "%%i" "%%~dpi./../")
pause
添加其所在文件夹的名称前缀
@echo off
rem 在多个子文件夹里的jpg文件的名称前面/开头添加其所在文件夹的名称前缀
mode con lines=3000
set "folder=D:\天翼云盘下载\新建文件夹"
if not exist "%folder%" (echo;"%folder%" no found&goto end)
if "%folder:~-1%" equ "\" set "folder=%folder:~,-1%"
for /f "delims=" %%a in ('dir /ad/b "%folder%\"') do (
pushd "%folder%\%%~nxa\"
for /f "delims=" %%b in ('dir /a-d/b *.jpg 2^>nul') do (
echo;"%%~nxa\%%~nxb" --^> "%%~nxa_%%~nxb"
ren "%%b" "%%~nxa_%%~nxb"
)
popd
)
:end
echo;%#% +%$%%$%/%@% %z%
pause
exit
文件新建文件夹并取名
md tbwind
for %%f in (*.*) do md tbwind\%%f
for %%f in (*.*) do move %%f tbwind\%%f\
xcopy tbwind\*.* /s
rd tbwind /s/q
去掉小箭头
/* ---去掉小箭头----*/
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "%systemroot%\system32\imageres.dll,197" /t reg_sz /f
taskkill /f /im explorer.exe
attrib -s -r -h "%userprofile%\AppData\Local\iconcache.db"
del "%userprofile%\AppData\Local\iconcache.db" /f /q
start explorer
pause
复制上面的代码。新建一个文本文件。粘贴后另存为.bat文件,然后以管理员身份打开。
ok!
/* ---恢复小箭头----*/
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /f
taskkill /f /im explorer.exe
attrib -s -r -h "%userprofile%\AppData\Local\iconcache.db"
del "%userprofile%\AppData\Local\iconcache.db" /f /q
start explorer
Pause
同理,将上述代码另存为.bat文件,管理员身份打开。就可恢复小箭头了。
目录中文件移出
@echo off
set son=%cd%
[url=home.php?mod=space&uid=251666]@rem[/url] 获取上级目录,暂时没使用到
pushd %son%
cd ..
set parent=%cd%
popd
for /d %%i in (*) do (
move /y %son%\%%i\*.* %son%
rd %son%\%%i
)
@Rem pause
清理文件
@echo off
pause
echo 正在清理系统垃圾文件,请稍等......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 清理系统垃圾完成!
echo. & pause
win10图片查看器
Windows Registry Editor Version 5.00
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.jpg]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.jpeg]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.gif]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.png]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.bmp]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.tiff]
@="PhotoViewer.FileAssoc.Tiff"
; Change Extension's File Type
[HKEY_CURRENT_USER\Software\Classes\.ico]
@="PhotoViewer.FileAssoc.Tiff"
多文件批量分成多个小文件夹
@echo off&setlocal enabledelayedexpansion
::文件分类管理:按每5个文件装进一个文件夹整理。move为移动 copy为复制
echo;&echo; 开始整理……&echo;
set newf=0
set numf=0
set conf=0
if not exist New!newf! md New!newf!
for /f "tokens=*" %%a in ('dir /b /a-d') do (
if !numf! geq 5 set numf=0&set /a newf+=1&md New!newf!
if not "%%~na"=="%~n0" move "%%~a" New!newf!&set /a numf+=1
set /a conf=!newf!*5+!numf!
)
echo;&echo; 整理完成,共 !conf! 个文件,请注意检查!&pause>nul
转载请注明:有爱前端 » bat批量处理 文件改名 移动文件 分批文件