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 文件可放任意位置運行