Script

Windows上bat批处理命令

bat 批量删除文件名中的空格

1
2
3
4
5
@echo off
Setlocal Enabledelayedexpansion
set "str= "
for /f "delims=" %%i in ('dir /b *.*') do (
set "var=%%i" & ren "%%i" "!var:%str%=!")

bat 批量删除文件名中的括号

1
2
3
4
5
6
7
8
@Echo Off&SetLocal ENABLEDELAYEDEXPANSION
FOR %%a in (*) do (
set "name=%%a"
set "name=!name:(=!"
set "name=!name:)=!"
ren "%%a" "!name!"
)
exit

bat 批量替换文件名中的特殊符号(以下将”_”改为”.”)

1
2
3
4
5
6
7
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%f in ('dir /b /a-d *_*.*') do (
if not "%%f"=="%0" (
set fn=%%~nxf
set fn=!fn:_=.!
ren "%%f" "!fn!"
))

bat 批量给文件名添加前缀字符

1
for %%i in (*.*) do ren "%%i" 前缀字符."%%i"

bat 批量删除文件名的末尾字符

1
2
3
4
5
6
7
8
9
@echo off
::Deep Lee
setlocal enabledelayedexpansion
for %%f in (*.wav) do ( *[注释]:这里的.wav,是你要指定批量处理的文件后缀名(可以根据不同后缀修改,例如pdf,txt,jpg等)*
echo %%f
set name=%%f
ren !name! !name:~0,9%!.wav *[注释]:如果将9改为-5,则是从右向左删除5位,如果将9改为-6,则是从右向左删除6位,以此类推,(此处的.wav算4个字符,这里算是默认自动补齐了,实际上是先删后加的)
)
pause

bat 批量删除/修改文件名中的某些字符串

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@echo off
set /p str1= 请输入要替换的文件(文件夹)名字符串(可替换空格):
set /p str2= 请输入替换后的文件(文件夹)名字符串(若删除直接回车):
echo.
echo 正在操作中,请稍候……
for /f "delims=" %%a in ('dir /s /b ^|sort /+65535') do (
if "%%~nxa" neq "%~nx0" (
set "file=%%a"
set "name=%%~na"
set "extension=%%~xa"
call set "name=%%name:%str1%=%str2%%%"
setlocal enabledelayedexpansion
ren "!file!" "!name!!extension!" 2>nul
endlocal
)
)
exit

bat 批量对文件名重命名

1
2
3
4
5
6
7
8
@echo off
setlocal enabledelayedexpansion
set n=1
for /f %%i in ('dir /b *') do (
ren "%%i" A!n!.apk
set /a n+=1)
echo 批量重命名完成! *[注释]:文件下所有文件都被命名成A1.apk、A2.apk、A3.apk…………
pause

bat 批量替换文件夹名称中的空格为指定字符

1
2
3
4
5
6
7
8
9
10
11
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir /ad/b/s^|sort /r') do (
set b=%%~nxi
set b=!b: =_! *[注释]: "set b=!b: =_!" 将空格替换成"_"下划线
echo %%i
echo !b!
ren "%%i" !b!
)
endlocal
exit

Windows上用bat部署Hexo博客

1
2
@echo off
start cmd /k "cd/d C:\Users\myth\HexoPage &&hexo clean &&hexo g -d &&hexo clean &&taskkill /f /t /im cmd.exe"

Mac上用bash部署Hexo博客

1
2
3
4
5
6
7
8
9
10
11
12
# hexopush.command
#! /bin/bash
cd /Users/myth/sunwucheng.github.io
hexo clean
git add .
git commit -m "automatic push"
git push origin hexo
hexo clean
hexo g -d
hexo clean
osascript -e 'tell application "Terminal" to quit' &
exit

win7原版镜像注入USB3.0和nvme驱动

如何让PPT导出的图片分辨率达到300dpi