1. 文件名前批量、随机、添加序号(批处理.bat)
试试VBS 脚本,复制以下内容,新建记事本。粘贴后保存:
类型选所有,文件名:文件名前批量.vbs,编码选择:ANSI
dim fnew,newf,arr
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path)
Set oFiles = oFolder.Files
ss= oFiles.count
For Each oFile In oFiles
if fso.GetExtensionName(oFile.Path) <> "mp3" then ss=ss - 1
next
arr = split(RndNub(ss),",")
newf = 0
For Each oFile In oFiles
if fso.GetExtensionName(oFile.Path) ="mp3" then
i = arr(newf)
oFile.name = left("0000", 4-len(i)) & i & "_" & oFile.name
newf = newf + 1
end if
next
msgbox "Done!",64,"TXT"
Function RndNub(ReqNub)
dim rds
Randomize
Set myList=CreateObject("System.Collections.ArrayList")
for i = 0 to 9999
myList.add(i)
next
for i=0 to ReqNub-1
index = Int((10000-i) * Rnd)
rds =rds & mylist.Item(index) & ","
myList.RemoveAt(index)
next
RndNub = rds
End Function
2. 批处理 查找选择文件夹中最新文件
@echooff
cd/d"c:A"
for%%iin(fulldiff)do(
for/f"tokens=3delims=_"%%jin(
'dir/b/ondatabase_%%i_*.bak')doset"%%i=%%j")
"database_full_%full%.bak""C:B"
if"%diff%"gtr"%full%""database_diff_%diff%.bak""C:B"
pause
注:此代码为按文件名排序取的最新文件,保存为xx.bat 文件可放任意位置运行