Einzelnen Beitrag anzeigen
Alt 24.08.2006, 16:13   #16
jar
Benutzer
 
Registriert seit: 24.01.2005
Ort: glücklicherweise wieder daheim
Beiträge: 21.532
Standard AW: Tool zum Ordner vergleichen

mini Lösung gebastelt

in einem Bilderordner habe ich die Vorschau JPG zum schnellen durchsehen und löschen, leider werden die raw im Unterordner RAW nicht mitgelöscht, deswegen dieses VBS

suche im Unterordner RAW alle raws, wenn es dazu kein JPG Gegenstück ein Ordner höher gibt, verschiebe das RAW in den bak Ordner

der kann dann manuell gelöscht werden

so sind immer nur die RAW da zu denen es auch Vorschau JPG gibt, ausser es gibt keine JPG weil man nur in RAW fotografiert hat, dann sind die wenigstens
noch im BAK Ordner

Zeile 20 : hier kann das Start Laufwerk und Verzeichnis vorgegeben werden
Zeile 21 : der RAW Typ, TIF, NEF, CRW, CR2
Zeile 22 : das BAK Verzeichnis, welches wenn nicht vorhanden , erstellt wird

den Code kopieren und als raw_del.vbs speichern, viel Spass

Code:
'v3.6*****************************************************
' File:   Datei-Verzeichnis-Liste.vbs
' Autor:  dieseyer@gmx.de 
'         http://dieseyer.de
'*********************************************************
'
' NEW BUILD by J A R -> RAW_DEL_1.vbs
'
'
'
Option Explicit ' Siehe http://dieseyer.de/dse-wsh-lernen.html#OptionExpl
Dim WSHShell, fso, oArgs
Dim oFolders, oSubFolder, oFiles, Folder
Dim i, j, k, f, Text, jpgPfad, rawPfad, DateiX, VerzX, Verz(), Datei(), jpgDatei(), rawTyp, intLaenge, warte
Dim objFSO, out_text, START_drv_dir, bak_dir
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fso      = WScript.CreateObject("Scripting.FileSystemObject")
set oArgs    = Wscript.Arguments 

START_drv_dir = "R:\test" ' kann angepasst werden auf das default Laufwerk und default BilderDIR
rawTyp = "tif"              ' RAW Type ;-) kann auch NEF , CRW, CR2 sein 
bak_dir = "bak"             ' im JPG Ordner wird ein bak erstellt, dorthin werden die überflüssigen RAW verschoben, kann jeder selber löschen
rawPfad = "\RAW"            ' da wollte jemand seinen RAW Ordner anders benennen :-)))
warte = 250                 ' hier kann man tunen 250 = 1/4 Sekunde


Dim oFSO, oFolder

' Globale Variablen für das Statusfenster
Dim oIEStatus, oTempFile, sTempFileName', WshShell

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(BrowseForFolder("Choose a folder (search in RAW)", 9, START_drv_dir))
'Set oFolder = oFSO.GetFolder("c:\test")
rawPfad = oFolder.Path & rawPfad
jpgPfad = oFolder.Path

i=0
'Wenn Ordner schon existiert, dann nicht neu erstellen
If FSO.FolderExists(jpgPfad & "\" & bak_dir & "\") = False Then
	'Ordner soll erstellt werden
	FSO.CreateFolder(jpgPfad & "\" & bak_dir & "\")
	Do While ( i<40 and not FSO.FolderExists(jpgPfad & "\" & bak_dir & "\") )
		WScript.Sleep 250
		i=i+1
	Loop
	
End If
 
if not fso.FolderExists( rawPfad ) then
  MsgBox rawPfad & "   existiert nicht!" & vbCRLF & vbCRLF & " . . . das ist das Ende.", , WScript.ScriptName
  WScript.Quit
End If

Set oFolders = fso.GetFolder( rawPfad )  
Set oFiles   = oFolders.Files

j=0
k=0

Call InitStatusWindow(oIEStatus)

f=0
For Each DateiX In oFiles
	If f = 0 Then
		f=f+1
		out_text = "working : " 
	Else
		f=0
		out_text = "        : " 
	End If
	'DateiX.Name
	Text=DateiX.Name
	out_text = out_text & DateiX.Name & vbCRLF
	Call WriteStatusText(oIEStatus, out_text )
	
	If Lcase(Right(DateiX.Name,3))=rawTyp Then ' wenn tif vorhanden
	   k=k+1
	   'MsgBox "1 " & rawPfad & "\" & Text, , WScript.ScriptName    
		Text=Lcase(Left(DateiX.Name, Len(DateiX.Name)-3)) & "jpg" ' suche jpg
		Text= jpgPfad & "\" & Text
	
   	If (fso.FileExists(Text)) Then ' jpg vorhanden
    	'j=j+1
    	'MsgBox "2 " & Text, , WScript.ScriptName    
      	'msg = filespec & " exists."
   	Else
		If FSO.FolderExists(jpgPfad & "\" & bak_dir & "\") = False Then
			MsgBox "Bei Erstellung des Ordners " & UCase(jpgPfad & "\" & bak_dir & "\") & " ist ein Fehler aufgetreten."
			WScript.Quit
		End If
		out_text = "MOVE : " & rawPfad & "\" & DateiX.Name & vbCRLF

		FSO.CopyFile (rawPfad & "\" & DateiX.Name), (jpgPfad & "\" & bak_dir & "\" & DateiX.Name) , True
		FSO.DeleteFile (rawPfad & "\" & DateiX.Name), True

		Call WriteStatusText(oIEStatus, out_text )
		WScript.Sleep (5 * warte )
		
   	End If
   	'Response.Write Text
	End If
	WScript.Sleep warte
Next

Set oFiles   = nothing
Set oFolders = Nothing
Call CloseStatusWindow(oIEStatus)


'MsgBox "FERTIG ! " 

'http://72.14.221.104/search?q=cache:S6jLbfL3kyQJ:www.aspheute.com/artikel/20020131.htm+fso.FileExists&hl=de&gl=de&ct=clnk&cd=1



'fso.MoveFile i.path, True

'http://www.google.de/search?hl=de&q=vbs+system+delete+move&meta=cr%3DcountryDE

sub CreateTempFile
  Dim tfolder, tname, tfile
  Const TemporaryFolder = 2

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set tfolder = objFSO.GetSpecialFolder(TemporaryFolder)
  sTempFileName = objFSO.GetTempName
  Set oTempFile = tfolder.CreateTextFile(sTempFileName)
  sTempFileName = tfolder.path & "\" & sTempFileName '"move del2bak" '
  Set tfolder = Nothing
  Set objFSO = Nothing
End Sub
  
Sub DeleteTempFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  objFSO.DeleteFile(sTempFileName)
  Set objFSO = Nothing
End Sub

Function InitStatusWindow(o_IEStatus)
  Dim WSHShell
  
  Set o_IEStatus = WScript.CreateObject("InternetExplorer.Application")
  With o_IEStatus
	.Visible = True
	.Height = 120
	.Width = 400
    .top = 598
    .left = 10
	.StatusBar = False: .MenuBar = False: .ToolBar = False
  
	call CreateTempFile
	oTempFile.WriteLine("noch leer ")
	oTempFile.Close
	o_IEStatus.Navigate sTempFileName '"move del2bak" '
	
	'Do
    'Loop While .Busy

    Set WSHShell = WScript.CreateObject("WScript.Shell")
    WshShell.AppActivate("Microsoft Internet Explorer")
    Set WSHShell = Nothing
  End With

End function  	

Function WriteStatusText(o_IEStatus, i_StatusText)
  With o_IEStatus
   	call CreateTempFile
	oTempFile.WriteLine(i_StatusText)
	oTempFile.Close
	o_IEStatus.Navigate sTempFileName '"move del2bak" '
  End with
End Function

Function CloseStatusWindow(o_IEStatus)
  o_IEStatus.Stop: o_IEStatus.Quit
  Set o_IEStatus = Nothing
  call DeleteTempFile
End Function


'*********************************************************
Function BrowseForFolder(strPrompt, intBrowseInfo, vRootFolder)
'*********************************************************
'BrowseForFolder dialog. Follows MSDN example closely. Also handles selection of special
'folders (ex Desktop), which do not return a folder3 object as 'normal' folders do.
'Code below does not support all options, only folders.
'To use, copy and paste function into script,
'call as BrowseForFolder(strPrompt, intBrowseInfo, vRootFolder) where root folder is either an
'integer (constants below) or a string with a folder path.
'To use the constants below, they must be in the script header.

	'Flags specifying the options for the dialog box. This member can include zero or a combination of the following values.
	 Const BIF_BROWSEFORCOMPUTER 	= 4096  'Only return computers. If the user selects anything other than a computer, the OK button is grayed.
	 Const BIF_BROWSEFORPRINTER 	= 8192  'Only allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed. In Microsoft Windows XP, the best practice is to use an XP-style dialog, setting the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS).
	 Const BIF_BROWSEINCLUDEFILES 	= 16384 'Version 4.71. The browse dialog box will display files as well as folders.
	'Const BIF_BROWSEINCLUDEURLS 	=       'Version 5.0. The browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES flags must also be set. If these three flags are not set, the browser dialog box will reject URLs. Even when these flags are set, the browse dialog box will only display URLs if the folder that contains the selected item supports them. When the folder's IShellFolder::GetAttributesOf method is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute flag. Otherwise, the browse dialog box will not display the URL.
	 Const BIF_DONTGOBELOWDOMAIN 	= 2     'Do not include network folders below the domain level in the dialog box's tree view control.
	 Const BIF_EDITBOX 		= 16    'Version 4.71. Include an edit control in the browse dialog box that allows the user to type the name of an item.
	'Const BIF_NEWDIALOGSTYLE 	=       'Version 5.0. Use the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands. To use this flag, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.
	 Const BIF_NONEWFOLDERBUTTON 	= 512   'Version 6.0. Do not include the New Folder button in the browse dialog box.
	'Const BIF_NOTRANSLATETARGETS 	=       'Version 6.0. When the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target.
	 Const BIF_RETURNFSANCESTORS 	= 8     'Only return file system ancestors. An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed. Const BIF_RETURNONLYFSDIRS = 1 'Only return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed.
	'Const BIF_SHAREABLE 		=       'Version 5.0. The browse dialog box can display shareable resources on remote systems. It is intended for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must also be set.
	 Const BIF_STATUSTEXT 		= 4     'Include a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
	'Const BIF_UAHINT 		=       'Version 6.0. When combined with BIF_NEWDIALOGSTYLE, adds a usage hint to the dialog box in place of the edit box. BIF_EDITBOX overrides this flag.
	'Const BIF_USENEWUI 		=       'Version 5.0. Use the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE. To use BIF_USENEWUI, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.
	 Const BIF_VALIDATE 		= 32    'Version 4.71. If the user types an invalid name into the edit box, the browse dialog box will call the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified.
	
	Const ssfALTSTARTUP 		= 29    'File system directory that corresponds to the user's nonlocalized Startup program group. (value = 29)
	Const ssfAPPDATA 		= 26    'Version 4.71. File system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. (value = 26)
	Const ssfBITBUCKET 		= 10    'Virtual folder containing the objects in the user's Recycle Bin. (value = 15)
	Const ssfCOMMONALTSTARTUP 	= 30    'File system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Microsoft Windows NT systems. (value = 30)
	Const ssfCOMMONAPPDATA 		= 35    'Version 5.0. Application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data. (value = 35)
	Const ssfCOMMONDESKTOPDIR 	= 25    'File system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT systems. (value = 25)
	Const ssfCOMMONFAVORITES 	= 31    'File system directory that serves as a common repository for all users' favorite items. Valid only for Windows NT systems. (value = 31)
	Const ssfCOMMONPROGRAMS 	= 23    'File system directory that contains the directories for the common program groups that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT systems. (value = 23)
	Const ssfCOMMONSTARTMENU 	= 22    'File system directory that contains the programs and folders that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems. (value = 22)
	Const ssfCOMMONSTARTUP 		= 24    'File system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems. (value = 24)
	Const ssfCONTROLS 		= 3     'Virtual folder containing icons for the Control Panel applications. (value = 3)
	Const ssfCOOKIES 		= 33    'File system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies. (value = 33)
	Const ssfDESKTOP 		= 0     'Microsoft Windows Desktop—virtual folder that is the root of the namespace. (value = 0)
	Const ssfDESKTOPDIRECTORY 	= 16    'File system directory used to physically store the file objects that are displayed on the desktop. It is not to be confused with the desktop folder itself, which is a virtual folder. A typical path is C:\Documents and Settings\username\Desktop. (value = 16)
	Const ssfDRIVES 		= 17    'My Computer—virtual folder containing everything on the local computer: storage devices, printers, and Control Panel. This folder may also contain mapped network drives. (value = 17)
	Const ssfFAVORITES 		= 6     'File system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites. (value = 6)
	Const ssfFONTS 			= 20    'Virtual folder containing installed fonts. A typical path is C:\WINNT\Fonts. (value = 20)
	Const ssfHISTORY	 	= 34    'File system directory that serves as a common repository for Internet history items. (value = 34)
	Const ssfINTERNETCACHE 		= 32    'File system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Temporary Internet Files. (value = 32)
	Const ssfLOCALAPPDATA 		= 28    'Version 5.0. File system directory that serves as a data repository for local (non-roaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data. (value = 28)
	Const ssfMYPICTURES 		= 39    'My Pictures folder. A typical path is C:\Documents and Settings\username\My Documents\My Pictures. (value = 39)
	Const ssfNETHOOD 		= 19    'A file system folder containing the link objects that may exist in the My Network Places virtual folder. It is not the same as ssfNETWORK, which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood. (value = 19)
	Const ssfNETWORK 		= 21    'Network Neighborhood—virtual folder representing the root of the network namespace hierarchy. (value = 18)
	Const ssfPERSONAL 		= 5     'File system directory that serves as a common repository for a user's documents. A typical path is C:\Documents and Settings\username\My Documents. (value = 5)
	Const ssfPRINTERS 		= 4     'Virtual folder containing installed printers. (value = 4)
	Const ssfPRINTHOOD 		= 18    'File system directory that contains the link objects that may exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood. (value = 27)
	Const ssfPROFILE 		= 40    'Version 5.0. User's profile folder. (value = 40)
	Const ssfPROGRAMFILES 		= 38    'Version 5.0. Program Files folder. A typical path is C:\Program Files. (value = 38)
	Const ssfPROGRAMS 		= 2     'File system directory that contains the user's program groups (which are also file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs. (value = 2)
	Const ssfRECENT 		= 8     'File system directory that contains the user's most recently used documents. A typical path is C:\Documents and Settings\username\Recent. (value = 8)
	Const ssfSENDTO 		= 9     'File system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo. (value = 9)
	Const ssfSTARTMENU 		= 11    'File system directory containing Start menu items. A typical path is C:\Documents and Settings\username\Start Menu. (value = 11)
	Const ssfSTARTUP 		= 7     'File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT or starts Windows 95. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup. (value = 7)
	Const ssfSYSTEM 		= 37    'Version 5.0. System folder. A typical path is C:\WINNT\SYSTEM32. (value = 37)
	Const ssfTEMPLATES 		= 21    'File system directory that serves as a common repository for document templates. (value = 21)
	Const ssfWINDOWS 		= 36    'Version 5.0. Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\WINNT. (value = 36)
	
	Dim oShell
	Dim oFolder
	Dim oFolderItem
	Dim strPath
	Dim oWSHShell
	Dim oFSO
	Dim bSuccess

	Set oShell = CreateObject("Shell.Application")
	Set oWSHShell = CreateObject("WScript.Shell")
	Set oFSO = CreateObject("Scripting.FileSystemObject")
	
	Do
		'syntax: oFolder = Shell.BrowseForFolder(Hwnd, sTitle, iOptions [,vRootFolder])
		Set oFolder = oShell.BrowseForFolder(&H0, strPrompt, intBrowseInfo, vRootFolder)
		
		'This seems to get a 'normal' folder object from the folder3 object returned by BrowseForFolder
		Set oFolderItem = oFolder.Items.Item
		
		'If a special folder (ex. desktop) is selected, object is nothing.
			If (oFolderItem Is Nothing) Then
			'This is necessary - seems to convert invalid object reference to a string?
			strPath = oFolder
			Set oFolderItem = oFSO.GetFolder(oWSHShell.SpecialFolders(strPath))
		End If
		
		If Not oFSO.FolderExists(oFolderItem.Path) Then
			MsgBox "Invalid selection; Please try again"
		Else
			bSuccess = True
		End If
	Loop While Not bSuccess
	
	BrowseForFolder = oFolderItem.Path

End Function ' BrowseForFolder(strPrompt, intBrowseInfo, vRootFolder)
__________________
meine Bilder dürfen hier bearbeitet werden und im Thread wieder eingestellt werden
"There are 10 Types of People in the World; who understand B I N A R Y and those who don't"
gruss
jar

Geändert von jar (25.08.2006 um 15:40 Uhr)
jar ist offline   Mit Zitat antworten