Source language: Translate to:

File and Folder functions

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

File and Folder functions

Postby dpayer » Fri Aug 24, 2012 7:46 am

I put together the following functions to assist in my File Explorer project.

You can view/download it here..

Image

These expand a bit what can be done with native NB commands. I normally like to attribute the original source of these but I didn't record them. Suffice it to say, we are indebted to the work of others (and they often got their samples from Microsoft's TechNet for VBS scripts).

Rename/Move/Copy/Delete files
Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|Variable containing desired action: Rename, Move, Copy, Delete
Param=[%2]|Variable|Selected file (path included) to act upon
Param=[%3]|Variable|Destination: variable containing file name and path
{End}
Dim fileaction, selectedfile, destinationobject, basefilename, parentpathname, desination2object

Set objFSO = CreateObject("Scripting.FileSystemObject")
fileaction = publication.nbGetVar( "[%1]" )
MsgBox (fileaction)
selectedfile = publication.nbGetVar( "[%2]" )
MsgBox (selectedfile)
destinationobject = publication.nbGetVar( "[%3]" )
MsgBox (desinationobject)
basefilename = objFSO.GetFileName(selectedfile)
MsgBox (basefilename)
parentpathname = objFSO.GetParentFolderName(selectedfile)
MsgBox (parentpathname)

popuptext ="FileAction = " & fileaction  &Chr(13)&"SelectedFile: " & selectedfile & Chr(13) & Chr(13)&"DestinationObject:" & destinationobject &Chr(13)& "BaseFileName: " & basefilename &Chr(13)& "ParentPath: " & parentpathname
MsgBox (popuptext)

Select Case fileaction
Case "Rename"

destination2object = parentpathname & "\" & destinationobject
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile selectedfile , destination2object


Case "Move"
destination2object = destinationobject & "\" & basefilename
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile selectedfile , destination2object


case "Delete"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(SelectedFile)

case "Copy"
Const OverwriteExisting = True
destination2object = destinationobject & "\"
destination2object = (Replace(destination2object,"\\","\"))
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile SelectedFile , destination2object, OverwriteExisting

End Select

Set objFSO = Nothing


File Properties

Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|absolute path to file
Param=[%2]|Variable|NB variable to receive list
{End}
NBselectedfile = publication.nbGetVar("[%1]")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set selectedfile = filesys.GetFile(NBselectedfile)
path = filesys.GetAbsolutePathName(NBselectedfile)
filecreatedate = selectedfile.DateCreated
filelastmodified = selectedfile.DateLastModified
filesize = selectedfile.Size
fileextension = filesys.GetExtensionName(path)
filetype = selectedfile.Type
fileversion = filesys.GetFileVersion(path)
finalstring = "Path: " & Chr(9) & path & chr(13) & "FileCreateDate: " & chr(9) & filecreatedate & chr(13) & "FileLastModified: " & chr(9) & filelastmodified & chr(13) & "FileSize: " & chr(9) & filesize & chr(13) & "FileExtension: " & chr(9) & fileextension & chr(13) & "FileType: " & chr(9) & filetype & chr(13) & "FileVersion: " & chr(9) & fileversion & chr(13)
publication.nbSetVar "[%2]", finalstring



Folder Properties
Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|Folder to enumerate properties
Param=[%2]|Variable|NB variable to return enumerated properties.
Param=[%3]|Variable|NB variable with string list of subfolders
{End}
Folderpath = nbGetVar("[%1]")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Folderpath)
FolderDateCreated = objFolder.DateCreated
FolderDateLastAccessed = objFolder.DateLastAccessed
FolderDateLastModified = objFolder.DateLastModified
FolderParentFolder = objFolder.ParentFolder
FolderSize = objFolder.Size
FolderType = objFolder.Type

FolderProperties = ("Folder Created: " & FolderDateCreated & Chr(13) &"Last Modified: " & FolderDateLastModified & Chr(13) & "Parent Folder: " & FolderParentFolder & Chr(13) & "Size: " & FolderSize & Chr(13) & "Type: " & FolderType)

publication.nbSetVar "[%2]", FolderProperties


Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
    Subfolderlist = Subfolderlist & objSubfolder.Name & Chr(9) &" size: "& objSubfolder.Size & Chr(13)

Next
publication.nbSetVar "[%3]", Subfolderlist



The following I wanted to put into one function as I did with the file functions but the CaseSelect just didn't work right, so I split them up:

Copy Folder
Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|Primary folder ( copy FROM, etc)
Param=[%2]|Variable|Secondary folder (copy TO, etc.)
{End}
Set objFSO = CreateObject("Scripting.FileSystemObject")
SecondaryFolder=publication.nbGetVar( "[%2]" )
PrimaryFolder=publication.nbGetVar( "[%1]" )
       
       Const OverWriteFiles = True

       objFSO.CopyFolder (PrimaryFolder) , (SecondaryFolder) , OverWriteFiles

       

set objFSO=nothing

On Error Resume Next
If Err.Number <> 0 Then
myerrormsg = ("Error Number: " & Err.Number & " Error Source: " & Err.Source & " Desc: " &  Err.Description)
Err.clear
    MsgBox (myerrormsg)
    End If



Delete Folder - will force delete of all child content

Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|Variable containing name of folder to remove
{End}
Set objFSO = CreateObject("Scripting.FileSystemObject")
PrimaryFolder=publication.nbGetVar( "[%1]" )


       Set objFSO = CreateObject ("Scripting.FileSystemObject")
 
      objFSO.DeleteFolder PrimaryFolder, force

      On Error Resume Next
          If Err.Number <> 0 Then
          myerrormsg = ("Error Number: " & Err.Number & " Error Source: " & Err.Source & " Desc: " &  Err.Description)
          Err.clear
          MsgBox (myerrormsg)
          End if


set objFSO=nothing

On Error Resume Next
If Err.Number <> 0 Then
myerrormsg = ("Error Number: " & Err.Number & " Error Source: " & Err.Source & " Desc: " &  Err.Description)
Err.clear
    MsgBox (myerrormsg)
    End If



Rename Folder

Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|Primary folder (move FROM, copy FROM, etc)
Param=[%2]|Variable|Secondary folder (move TO, copy TO, etc.)
{End}
Set objFSO = CreateObject("Scripting.FileSystemObject")

SecondaryFolder=publication.nbGetVar( "[%2]" )
PrimaryFolder=publication.nbGetVar( "[%1]" )

       Set objFSO = CreateObject("Scripting.FileSystemObject")
       objFSO.MoveFolder (PrimaryFolder) , (SecondaryFolder)

      On Error Resume Next
          If Err.Number <> 0 Then
          myerrormsg = ("Error Number: " & Err.Number & " Error Source: " & Err.Source & " Desc: " &  Err.Description)
          Err.clear
          MsgBox (myerrormsg)
          End if

set objFSO=nothing

On Error Resume Next
If Err.Number <> 0 Then
myerrormsg = ("Error Number: " & Err.Number & " Error Source: " & Err.Source & " Desc: " &  Err.Description)
Err.clear
    MsgBox (myerrormsg)
    End If



I decided to use COPY/DELETE as an alternative to a direct MOVE command.
Last edited by dpayer on Mon Oct 03, 2016 11:34 am, edited 1 time in total.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Neosoft Support » Fri Aug 24, 2012 10:17 am

Very useful. Thank you for sharing.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby CN_Iceman » Fri Aug 24, 2012 2:20 pm

Interensting functions...

I am trying to use the File Properties function because I need to know de fileversion of some files.

The problem is that I can't use this function...

I understand that if I want to create that function, I must copy your text code and paste in a new VBScript function... It is that correct?

Greetings.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Postby dpayer » Fri Aug 24, 2012 2:31 pm

CN_Iceman wrote:Interensting functions...

I am trying to use the File Properties function because I need to know de fileversion of some files.

The problem is that I can't use this function...

I understand that if I want to create that function, I must copy your text code and paste in a new VBScript function... It is that correct?

Greetings.


Copy this part:
Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|absolute path to file
Param=[%2]|Variable|NB variable to receive list
{End}
NBselectedfile = publication.nbGetVar("[%1]")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set selectedfile = filesys.GetFile(NBselectedfile)
path = filesys.GetAbsolutePathName(NBselectedfile)
filecreatedate = selectedfile.DateCreated
filelastmodified = selectedfile.DateLastModified
filesize = selectedfile.Size
fileextension = filesys.GetExtensionName(path)
filetype = selectedfile.Type
fileversion = filesys.GetFileVersion(path)
finalstring = "Path: " & Chr(9) & path & chr(13) & "FileCreateDate: " & chr(9) & filecreatedate & chr(13) & "FileLastModified: " & chr(9) & filelastmodified & chr(13) & "FileSize: " & chr(9) & filesize & chr(13) & "FileExtension: " & chr(9) & fileextension & chr(13) & "FileType: " & chr(9) & filetype & chr(13) & "FileVersion: " & chr(9) & fileversion & chr(13)
publication.nbSetVar "[%2]", finalstring

and save it as a file with no extension and put that file in your functions folder. Give it a name like fileproperties.

In your Neobook IDE where you are coding, use the command "CALL" (type it in and then click it in the editor, a wizard will appear and you will then be able to find the function in the functions folder).

You will be prompted for two variable names. One is for the variable holding the path\filename info. The other is the variable you want to put this information into. When you run that code it will create a string with information as seen here:
Image
you can parse that string as needed. Example:
Code: Select all
StrParse "[mystring]" "FileVersion: " "[MyData]" ""


The version number will be in the variable [MyData2]

or you can modify the function to only provide what you need.

David P.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby CN_Iceman » Sat Aug 25, 2012 9:45 am

Thank's David...

The problem is that I made all exactly as you describe in your post (that's the way I use normally), but the function is not working...

Code: Select all
Call "Propiedades_Archivo" "C:\Program Files (x86)\NeoBook 5\NeoBook.exe" "[Variable]"


Image

Any idea?

Greetings.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Postby dpayer » Mon Aug 27, 2012 8:00 am

CN_Iceman wrote:Thank's David...

The problem is that I made all exactly as you describe in your post (that's the way I use normally), but the function is not working...

Code: Select all
Call "Propiedades_Archivo" "C:\Program Files (x86)\NeoBook 5\NeoBook.exe" "[Variable]"


Image

Any idea?

Greetings.


Yes, the function is written with the expectation that the name of the file will be given as a variable. Try doing that.

You can test if the function gets the name of the file properly by inserting a popup box after the nbGetVar line.

Code: Select all
NBselectedfile = publication.nbGetVar("[%1]")
MsgBox NBselectedfile


See if that helps.

David
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby CN_Iceman » Mon Aug 27, 2012 9:23 am

Yes... now it works perfect.
Thank's for the help David.

Greetings.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: File and Folder functions

Postby aguilar955 » Sun Nov 04, 2012 10:49 am

Gracias maginifico trabajo.

He observado que al renombrar un archivo y darle al boton cancelar sale una ventana con un mensaje de error.

Un archivo no puede ser copiado a si mismo y elimina el archivo seleccionado para renombrar.

Cuando se quiere eliminar dice que no lo ha encontrado y no lo elimina el archivo.

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Re: File and Folder functions

Postby dpayer » Mon Nov 05, 2012 9:01 am

aguilar955 wrote:Gracias maginifico trabajo.
He observado que al renombrar un archivo y darle al boton cancelar sale una ventana con un mensaje de error.
Un archivo no puede ser copiado a si mismo y elimina el archivo seleccionado para renombrar.
Cuando se quiere eliminar dice que no lo ha encontrado y no lo elimina el archivo.
Salu2


Translation:
Thank Magnificent work.
I noticed that when renaming a file and give the Cancel button get a window with an error message.
A file can not be copied and removed himself to rename the selected file.
When you want to delete it says not found and does not delete the file.
Salu2


I see the problem.

In the double click action on the listbox for file names there is a section called .rename
and in that section is the following code:
Code: Select all
.rename
           If "[fileoption]" "=" "3"
                  InputBox "Rename file" "[selectedfilelistitem]|Rename to:" "[filerename2]"
                  FileExists "[selectedfolder]\[filerename2]" "[filerename2exists]"
                         If "[filerename2exists]" "<>" "true"
                             FileCopy "[filepath3]" "[selectedfolder]\[filerename2]"
                             FileErase "[filepath3]"
                             .Call "FileActions" "Rename" "[filepath3]" "[selectedfolder]\[filerename2]"
                         
       
                          Else
                             Alertbox "Warning: File Exists" "The file [filerename2] exists. Use another name."
                             
                          Endif

                  GoSub "getfolderfileinfo"
      Endif


I use an Inputbox to get the new file name. But when you cancel, I don't do an error correction.

Here is how you can catch the error. First set the filerename2 variable to empty. Then do the Inputbox and afterward check to see if the variable is still empty. It appears that NB does not set the variable until you hit the ok button.

Code: Select all
If "[fileoption]" "=" "3"
                   SetVar "[filerename2]" ""
                  InputBox "Rename file" "[selectedfilelistitem]|Rename to:" "[filerename2]"
                  IF "[filerename2]" "<>" ""
                       FileExists "[selectedfolder]\[filerename2]" "[filerename2exists]"
                         If "[filerename2exists]" "<>" "true"
                             FileCopy "[filepath3]" "[selectedfolder]\[filerename2]"
                             FileErase "[filepath3]"
                             .Call "FileActions" "Rename" "[filepath3]" "[selectedfolder]\[filerename2]"
                         
       
                          Else
                             Alertbox "Warning: File Exists" "The file [filerename2] exists. Use another name."
                             
                          Endif
                   Else
                   GoSub "getfolderfileinfo"
                   Endif


            Endif


It also looks like I left some commented code in there (a dot in front of a line makes it a commented line). You can remove those if you want to clean up the code for yourself.

David P>
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: File and Folder functions

Postby aguilar955 » Mon Nov 05, 2012 4:35 pm

Gracias dpayer al final hice unos cambios en el objeto FolderList

Code: Select all
TimerStop "MultifilesTimer"
If "[selectedfilelistitem]" "=" ""
    Alertbox "Not Selected" "Select the file and then double click"
    GotoLine "endfileactions"
Endif
SetVar "[filerename2exists]" ""
SetVar "[filepath3]" "![selectedfolder]\[selectedfilelistitem]"
StrReplace "[filepath3]" "\\" "\" "[filepath3]" ""
If "[selectedfilelistitem]" "<>" ""
    If "[fileinfobuttonlabel]" "=" "ON"
        Call "Fileproperties" "[filepath3]" "[selectedfileproperties]"
        StickyNote "1" "197" "[selectedfileproperties]" "0"
    Endif
    MenuEx "23" "198" "Run/Open file| |Rename file|Move/Copy File|Delete file|Return" "[fileoption]" "-1" "-1"
    .run/open
    If "[fileoption]" "=" "1"
        GoSub "Limpia"
        Run "![selectedfolder]\[selectedfilelistitem]" "" "Normal" "" "[selectedfilerunID]"
        SearchStr "%1" "[LastError]" "[whoops]" ""
        If "[whoops]" ">" "0"
            MenuEx "89" "198" "Open in Notepad|Open in Wordpad|Open in Image Viewer|- - choose application" "[chooseapptorunfile]" "-1" "-1"
            If "[chooseapptorunfile]" "=" "1"
                DropFile "[SystemDir]notepad.exe" "[filepath3]"
            Else
                If "[chooseapptorunfile]" "=" "2"
                    DropFile "[#34]C:\Program Files\Windows NT\Accessories\wordpad.exe[#34]" "[filepath3]"
                Else
                    If "[chooseapptorunfile]" "=" "3"
                        Run "rundll32.exe" "[SystemDir]shimgvw.dll,ImageView_Fullscreen [filepath3]" "LoadComplete" "" ""
                    Else
                        If "[chooseapptorunfile]" "=" "4"
                            FileOpenBox "Select an application" "Any File|*.exe" "c:\" "[chooseapptorunfile]" ""
                            Run "[chooseapptorunfile]" "[filepath3]" "Normal" "" ""
                        Endif
                    Endif
                Endif
            Endif
        Endif
    Endif
    If "[fileoption]" "=" "2"
        .this doesn't work as expected... need to research how to load a file into any app
        .                                                    FileOpenBox "Select an application" "Any File|*.exe" "c:\" "[chooseapptorunfile]" ""
        .                                                               Run "[chooseapptorunfile]" "[filepath3]" "Normal" "" ""
    Endif
    .rename
    If "[fileoption]" "=" "3"
        .SetVar "[filerename2]" ""
        InputBox "Rename file" "[selectedfilelistitem]|Rename to:" "[filerename2]"
        If "[filerename2]" ">" ""
            FileExists "[selectedfolder][filerename2]" "[filerename2exists]"
            If "[filerename2exists]" "<>" "true"
                .FileCopy "[filepath3]" "[selectedfolder]\[filerename2]"
                .FileErase "[filepath3]"
                SetVar "[CurrentDir]" "[selectedfolder]"
                Run "cmd" "/c ren [#34][filepath3][#34] [#34][filerename2][#34]" "Wait+Hidden" "" ""
                .Call "FileActions" "Rename" "[filepath3]" "[selectedfolder]\[filerename2]"
            Else
                Alertbox "Warning: File Exists" "The file [filerename2] exists. Use another name."
            Endif
        Endif
        GoSub "getfolderfileinfo"
    Endif
    .move
    If "[fileoption]" "=" "4"
        MessageBox "Select Option" "" "Move|Copy" "[fileoption2]"
        If "[fileoption2]" "=" "1"
            FolderBox "Select a Folder:" "[move_copy_selected]"
            If "[move_copy_selected]" "=" "[selectedfolder]"
                Alertbox "Error" "Cannot 'move' to the same location. Select another folder"
            Else
                .Call "FileActions" "Move" "[filepath3]" "[move_copy_selected]\"
                FileCopy "[filepath3]" "[move_copy_selected]\[selectedfilelistitem]"
                FileErase "[filepath3]"
            Endif
            StickyNote "18" "222" "File moved to [move_copy_selected]" "750"
            GoSub "GetFolderFileInfo"
        Endif
        .copy
        If "[fileoption2]" "=" "2"
            MessageBox "Options" "Copy file to same location or new folder?" "Same location|New folder" "[newfilelocation]"
            .copy to same folder
            .get a copy of the filename
            SetVar "[tempfilename1]" "[selectedfilelistitem]"
            If "[newfilelocation]" "=" "1"
                SetVar "[tempfilename1]" "[selectedfilelistitem]"
                InputBox "Filename" "New name for copied file" "[tempfilename1]"
                FileExists "[selectedfolder]\[tempfilename1]" "[filerename2exists]"
                If "[filerename2exists]" "<>" "true"
                    FileCopy "[filepath3]" "[selectedfolder]\[tempfilename1]"
                    .Call "FileActions" "Copy" "[filepath3]" "[selectedfolder]\[tempfilename1]"
                Else
                    While "[filerename2exists]" "=" "True"
                        Loop "1" "9999" "[RandomWILL]"
                            FileExists "[selectedfolder]\[tempfilename1].[RandomWILL]" "[filerename2exists]"
                            If "[filerename2exists]" "<>" "true"
                                FileCopy "[filepath3]" "[selectedfolder]\[tempfilename1].[randomnum]"
                            Endif
                        Endloop
                    Endwhile
                    Alertbox "File name exists." "The destination folder\filename exists.|File renamed to [tempfilename1].[randomnum]"
                Endif
                GoSub "GetFolderFileInfo"
            Else
                .copy to new folder
                .get a copy of the filename
                SetVar "[tempfilename1]" "[selectedfilelistitem]"
                FolderBox "Select a Folder:" "[move_copy_selected]"
                If "[move_copy_selected]" "=" "[selectedfolder]"
                    Alertbox "Error" "Select another folder"
                Else
                    FileExists "[move_copy_selected]\[selectedfilelistitem]" "[filerename2exists]"
                    .=========
                    If "[filerename2exists]" "<>" "true"
                        FileCopy "[filepath3]" "[move_copy_selected]\[tempfilename1]"
                        .Call "FileActions" "Copy" "[filepath3]" "[move_copy_selected]\[selectedfilelistitem]"
                    Else
                        While "[filerename2exists]" "=" "True"
                            Loop "1" "9999" "[RandomWILL]"
                                FileExists "[move_copy_selected]\[tempfilename1].[RandomWILL]" "[filerename2exists]"
                                If "[filerename2exists]" "<>" "true"
                                    FileCopy "[filepath3]" "[move_copy_selected]\[tempfilename1]"
                                Endif
                            Endloop
                        Endwhile
                        Alertbox "File name exists." "The destination folder\filename exists.|File renamed to [tempfilename1].[randomnum]"
                    Endif
                Endif
                .==========

                .FileCopy "[selectedfolder]\[selectedfilelistitem]" "[move_copy_selected]\[selectedfilelistitem]"
                GoSub "GetFolderFileInfo"
            Endif
        Endif
    Endif
    .delete
    If "[fileoption]" "=" "5"
        .GoSub "Limpia"
        SetVar "[erase]" "[selectedfilelistitem]"
        MessageBox "Warning: File Deletion" "Do you want to delete [selectedfilelistitem]?" "Delete|Cancel" "[fileexistwarning]"
        If "[fileexistwarning]" "=" "1"
            FileErase "[selectedfolder][erase]"
            SetVar "[selectedfilelistitem]" "[erase]"
            GoSub "getfolderfileinfo"
        Endif
    Endif
    .return
    If "[fileoption]" "=" "6"
        SetVar "[selectedfilelistitem]" ""
    Endif
Endif

:endfileactions


Para renombar el archivo he usado...

SetVar "[CurrentDir]" "[selectedfolder]"
Run "cmd" "/c ren [#34][filepath3][#34] [#34][filerename2][#34]" "Wait+Hidden" "" ""

Y alguna cosilla mas, me a gustado mucho como has creado este proyecto.

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Re: File and Folder functions

Postby aguilar955 » Tue Nov 06, 2012 2:17 pm

Codigo VBS File Rename

Code: Select all
{NeoBook Function}
Version=5.60
Language=VBScript
Param=[%1]|FileName|Original file name:
Param=[%2]|FileName|New file name:
Param=[%3]|Variable|Variable to store result
{End}
set objWMI = GetObject("winmgmts:\\.\root\cimv2")
set objFile = objWMI.Get("Cim_Datafile='[%1]'")
intRC = objFile.Rename("[%2]")

publication.nbSetVar "[%3]", intRC


objeto FolderList


Code: Select all
    If "[fileoption]" "=" "3"
        InputBox "Rename file" "[selectedfilelistitem]|Rename to:" "[filerename2]"
        If "[filerename2]" ">" ""
            FileExists "[selectedfolder][filerename2]" "[filerename2exists]"
            If "[filerename2exists]" "<>" "true"
                Call "VBScript Examples\File Rename" "[filepath3]" "[selectedfolder][filerename2]" "[var]"
            Else
                Alertbox "Warning: File Exists" "The file [filerename2] exists. Use another name."
            Endif
        Endif
        GoSub "getfolderfileinfo"
    Endif


Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests