Showing posts with label delete fields. Show all posts
Showing posts with label delete fields. Show all posts

Friday, February 10, 2017

VBScript Delete All Files And SubFolders

VBScript is a scripting language to manage computer developed by Microsoft. It is important that we have power to do something using some script written by me. Below is a code snippet that delete all files & subfolders & files of subfolders easily.

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("C:\tmp\xxx")

'Delete all files in root folder
for each File in Folder.Files
    On Error Resume Next
    name = File.name
    File.Delete True
    If Err Then
        WScript.Echo "Error deleting:" & Name & " - " & Err.Description
    Else
        WScript.Echo "Deleted:" & Name
    End If
    On Error GoTo 0
Next

'Delete all subfolders and files
For Each File In Folder.SubFolders
    On Error Resume Next
    name = File.name
    File.Delete True
    If Err Then
        WScript.Echo "Error deleting:" & Name & " - " & Err.Description
    Else
        WScript.Echo "Deleted:" & Name
    End If
    On Error GoTo 0
Next

Friday, January 18, 2013

Cakephp delete and update records by conditions

Delete Records:
$this->ModelName->deleteAll(
    array(
        "ModelName.id" => 10
    )
);

Update Records:
$this->ModelName->updateAll(
    /* UPDATE FIELD */
    array(
        "ModelName.is_active" => 0,
    ),
    /* CONDITIONS */
    array(
        "ModelName.id" => 20,
        "ModelName.name LIKE" => '%SEARCH_TEXT%',
        "ModelName.name <>" => 'NOT_EQUAL_VALUE',
        'ModelName.integer_field > ' => 50, [Can use operand here]
        'TIMESTAMPDIFF(DAY, ModelName.date, NOW())' => 22 [number of day]
    )
);