![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Multiselect: useraccounts not working properly Hello, I wrote a script to change the name of the pictures taken with my camera. I select the pictures, write the name I want to give them and the numer from which I want to start renaming. The pictures are renamed in Birthday 001, Birthday 002, etc. One version uses SendTo. But has a limit in the lenght of the arguments in the pathname. With long pathnames I can only change the name to 10 to 15 pictures each time. With commondialog it does not run as I miss the license for the dll. With useraccounts it works but when I select about 30 files it acts like I didn't select anything. It seems there are no other properties to set in order to enlarge the comdlg.filename value . Is there a workaround or should I rename the pictures in grups? (After the snippet I put the code using SendTo or Drag&Drop, if anyone in interested) Set comDlg=CreateObject("UserAccounts.CommonDialog") const cdlOFNHideReadOnly = 4 'Nasconde la casella "sola lettura" const cdlOFNAllowMultiselect = 512 'Permette di selezionare più files const cdlOFNFileMustExist = 4096 'Puoi scegliere solo files esistenti comDlg.Flags = cdlOFNHideReadOnly + cdlOFNAllowMultiselect + cdlOFNFileMustExist comDlg.Filter = "Fotografie|*.jpg|Tutti i files|*.*|" comDlg.InitialDir="c:\" comdlg.FilterIndex = 1 comDlg.ShowOpen Lista=Split(comDlg.FileName," ") NumeroFiles=UBound(Lista) 'inizia da zero msgbox comdlg.filename msgbox numerofiles ---------------------------------------------- ' ***************************************************** ' QuickRename.vbs ' (c) Cenati Giovanni - http://digilander.libero.it/Cenati ' Scritto il 9 maggio 2007 ' Codice vbs liberamente utilizzabile citando il sito ' Trascinare diversi file sull'icona del programma ' per modificare il nome dei files. ' Se il nome fisso inserito è "Test File " (con uno spazio alla fine) ' e il numero dal quale iniziare è 13, ' i files trascinati sullo script saranno rinominati, previa conferma, ' in Test "File 013.jpg", "Test File 014.jpg", "Test File 015.jpg", ecc. ' Il numero di files selezionabili dipende dalla lunghezza della ' riga di comando di windows. La somma dei caratteri dei nomi dei files ' passati come argomento non può superare 256. ' ***************************************************** Dim Filenames(1000,2) Title= "QuickRename - by Cenati Giovanni" Set objArgs = WScript.Arguments 'Vedo se c'è almeno un argomento passato allo script If objargs.count=0 Then 'altrimenti mostro come si usa il programma msg= "Drag and drop files on the icon of the script " msg=msg & "to change the name of the files. " & vbCrlf msg=msg & "You will be prompted for a fixed name and a progressive number " msg=msg & "to be added to the name. The original extension will be maintained. " msg=msg & "It asks a confirmation before renaming. " msgbox msg ,,Title wscript.quit End If NumeroFiles = objargs.count -1 For i=0 To NumeroFiles Filenames(i,1)= objArgs(i) 'Metto in una matrice il nome dei files da rinominare Next Set fso = CreateObject("Scripting.FileSystemObject") NomeFisso = inputbox("Fixed name", title) NumIniziale = inputbox("Number where to start from ", title, "1") NumIniziale = cint(NumIniziale) msg="<pre>" For i=0 To NumeroFiles 'Memorizzo l'estensione del file da rinominare Estensione = fso.GetExtensionName(Filenames(i,1)) 'Memorizzo il percorso del file e ci aggiungo un "\" Percorso = fso.getparentfoldername(Filenames(i,1)) & "\" 'Trasformo in stringa "001" il numero che rappresenta il progressivo Numero = right("000" & NumIniziale,3) 'es: Trasforma 5 in 005 'Costruisce il nuovo filename Filenames(i,2)= Percorso & Nomefisso & Numero & "." & Estensione 'Prepara la riga con i due nomi di file. msg=msg & Filenames(i,1) & " --> " & Filenames(i,2) & vbCrlf NumIniziale = NumIniziale + 1 'Incrementa il numero progressivo Next '*** Crea una finestra che funge da output *** Set myIE = CreateObject("InternetExplorer.Application") myIE.Navigate "about:blank" myIE.ToolBar = False:myIE.StatusBar = False:myIE.Resizable = False Do Loop While myIE.Busy myIE.Width = 900:myIE.Height = 350 myIE.Left = 50:myIE.Top = 50 myIE.Visible = True myIE.document.writeln("<html><title></title>"&_ "<body bgcolor=antiquewhite><div id='cont'></div></body></html>") Set IEWindow = myIE.Document.All("cont") '********************************************** ' Mostra la preview della modifica dei nomi dei files IEWindow.INNERHTML = msg risp= msgbox( "Conferma Rinomina dei files?",vbYesno,Title) If risp=vbno Then MYie.QUIT:wscript.quit 'Se ha risposto si, procede a rinominare i files For i=0 To NumeroFiles fso.movefile Filenames(i,1),Filenames(i,2) Next MYie.QUIT wscript.quit -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Useraccounts after upgrade to SP2 | Windows Updates | |||
| Is this working properly? | Vista networking & sharing | |||
| NVMonitor not working properly - HELP! | Graphic cards | |||
| E-mails within different useraccounts? | Vista mail | |||
| Windows Explorer Multiselect Not Working | Vista General | |||