Sim, agora poderemos dar nomes aleatórios há vários arquivos reunidos numa pasta. Todos serão renomeados:
Function ReFileNameRandomly (Prefix As String, _FILEPATH As String, _nExtension As String, _FinalExtension As String)Dim strfile As StringDim filenum As StringDim SizeExtension As IntegerDim sFileNumber As StringLet strfile = Dir(FILEPATH)Let SizeExtension = Len(Replace(nExtension, ".", ""))Do While strfile <> ""Debug.Print strfileIf Right$(strfile, SizeExtension) = nExtension ThenLet filenum = Mid$(strfile, Len(strfile) - 6, SizeExtension)Let sFileNumber = Int((99999 - 10000 + 1) * Rnd + 10000)Name FILEPATH & strfile As FILEPATH & Prefix & sFileNumber & "." & FinalExtensionEnd IfLet strfile = DirLoopEnd Function
Tags: VBA, file, rename, folder, pasta, tips, randomly, aleatoriamente, aleatório, renomear