1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Dim oFso, oShell, sCurPath, sNewPath
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Shell.Application")
sCurPath = oFso.GetAbsolutePathName(".") & "\Tests\"
sNewPath = oFso.GetAbsolutePathName(".") & "\New\"
If Not oFso.FolderExists(sNewPath) Then ' Répertoire de destination pour conserver les originaux
oFso.CreateFolder(sNewPath)
End If
Dim f, fc, f1, sFile, sNewFile, sFileName, sFileExt, oFolder, oFile, sPicDate
Set f = oFso.GetFolder(sCurPath)
Set fc = f.Files
Set oFolder = oShell.NameSpace(sCurPath)
For Each f1 in fc
sFileName = oFso.GetBaseName(f1)
sFileExt = oFso.GetExtensionName(f1)
If Ucase(sFileExt) = "JPG" Then ' pour limiter aux seuls jpg
Set oFile = oFolder.Items.Item(sFileName & "." & sFileExt)
sDate = Left(oFolder.GetDetailsOf(oFile, 12),13)
Set oFile = Nothing
sPrefixe = Right(sDate,4) & Right("00" & Mid(sDate,6,2),2) & Right("00" & Left(sDate,3),2)
nRef = 0
sRef = Right("000" & Trim(Cstr(nRef)),3)
sNewFile = sNewPath & "\" & sPrefixe & sRef & "_" & sFileName & "." & sFileExt
Do While oFso.FileExists(sNewFile)
nRef = nRef + 1
sRef = Right("000" & Trim(Cstr(nRef)),3)
sNewFile = sNewPath & "\" & sPrefixe & sRef & "_" & sFileName & "." & sFileExt
Loop
oFso.CopyFile f1, sNewFile
End If
Next
Set f = Nothing
Set fc = Nothing
Set oFolder = Nothing
Set oShell = Nothing
Set oFso = Nothing
MsgBox("Ok") |
Partager