26-11-2005, 18:09
|
|
\dev\null
|
|
חבר מתאריך: 08.11.02
הודעות: 11,379
|
|
קצת עזרה ב-VBS
אני בונה קובץ ב-VBS שקורה לקובץ EXE לביצוע עבודה מסויימת
אבל מסיבה שלא מובנת לי הקריאה מתבצעת ואין לי תוצאה
הקובץ שנקרא הוא בשם CONVERT שמקבל קובץ תמונה ועם מספר פרמטרים מוציא לי תמונה מוקטנת
הקיראה מתבצעת אבל אני לא מקבל תמונה מעובדת...
קוד:
function CreateNewFolder(byVal Path, byVal NewFolderName)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim FullPath
FullPath = Path & NewFolderName
if Not objFSO.FolderExists(FullPath) Then
objFSO.CreateFolder(FullPath)
CreateNewFolder = True
Else
CreateNewFolder = False
End If
Set objFSO = nothing
End function
' ------------------------------------------
Dim objFSO
Dim objFolder
Dim FolderPath
Dim objFolder_Contain
Dim foundFile
Dim Crate_Folder_Named
Dim strFilename
Dim MaxFileSize
MaxFileSize = 59000
FolderPath = "f:\test\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set objFolder_Contain = objFolder.Files
Set oShell = CreateObject("WScript.Shell")
Crate_Folder_Named = "Renamed Files"
Call CreateNewFolder(FolderPath, Crate_Folder_Named)
Dim Prfix
Dim i
Dim Lenght
Lenght = 4
i=0
iRC = 0
For Each foundFile In objFolder_Contain
Prfix = ""
strFilename = foundFile.name
' ------------------------- Build The prefix for evry File ------------------------
For ii=1 to (Lenght-Len(i))
Prfix = Prfix & "0"
next
Prfix = Prfix & i
Extention = Right(strFilename, len(strFilename)-InStr(strFilename, "."))
'------------------------------------------------------------------------
Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.GetFile(foundFile) 'replace(MapPath(strFN), "%20", " "))
If (f1.Size > MaxFileSize) Then
' msgbox "convert -resize 90% " & f1 & " " & FolderPath & "test.jpg"
iRC = oShell.Run("convert -resize 90% " & f1 & " " & FolderPath & "test.jpg", 0, True)
'iRC = oShell.Run("ping 127.0.0.1 -t", 1, True)
If iRC <> 0 Then
WScript.Echo "Copy failed, convert returned error level " & iRC
Else
WScript.Echo "Convert finished"
End If
End If
f1.Copy(FolderPath & "\" & Crate_Folder_Named & "\" & Prfix & "." & Extention)
i = i+1
Next
Set objFSO = Nothing
'---------------------
Msgbox "DONE"
|