ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: delete files in one folder according to files in another folder

(1/2) > >>

lijieliang:
I have some files in one folder and these same files in another folder with a lot more files. How do I delete these files in that folder with a lot more files?
thank you in advance.

skwire:
To clarify, you have a list of files in, say, Folder A.  If those same filenames exist in Folder B, you want them deleted.  Is this correct?

lijieliang:
that's correct.

skwire:
Try this (source/binary included):  Download


--- Code: AutoIt ---; Set environment.SetBatchLines, -1SetControlDelay, -1DetectHiddenWindows, OnSetWorkingDir, %A_ScriptDir% ; Build main GUI.GoSub, Gui_Build_Main Return ; End of auto-execute section.  Gui_Build_Main:{    ; Build GUI.    Gui, Margin, 3, 5    Gui, Add, Text    , xm     ym    w50  h20 Right 0x200                  , Folder #1:    Gui, Add, Edit    , xm+55  ym    w270 h20             vFolder_1        ,    Gui, Add, Button  , xm+330 ym    w30  h20             vBrowse_1 gBrowse, ...    Gui, Add, Text    , xm     ym+25 w50  h20 Right 0x200                  , Folder #2:    Gui, Add, Edit    , xm+55  ym+25 w270 h20             vFolder_2        ,    Gui, Add, Button  , xm+330 ym+25 w30  h20             vBrowse_2 gBrowse, ...    Gui, Add, Button  , xm+170 ym+53 w190 h25             vDelete   gDelete, &Delete matching files to Recycle Bin    Gui, Add, Statusbar        SB_SetText( "Ready.", 1 )    GUI_ID := WinExist()    Gui, Show, AutoSize Center, Match & Recycle}Return  GuiEscape:GuiClose:{    ExitApp}Return  Delete:{    Gui, 1: Submit, NoHide     ; Basic pre-check.    If ( Folder_1 = "" OR Folder_2 = "" OR ! FileExist( Folder_1 ) OR ! FileExist( Folder_2 ) )    {        MsgBox, 48, Error, Please select valid folders.        Return    }     Loop, % Folder_1 . "\*.*", 0, 0    {        SB_SetText( "Processing: " . A_LoopFileName, 1 )         If FileExist( Folder_2 . "\" . A_LoopFileName )        {            FileRecycle, % Folder_2 . "\" . A_LoopFileName        }    }     SB_SetText( "Done.", 1 )}Return  Browse:{    Gui, 1: Submit, NoHide    If ( A_GuiControl = "Browse_1" )    {        Folder_1 := ""        FileSelectFolder, Folder_1, , 2, Select first folder.        If ( ErrorLevel != 1 )        {            GuiControl, Text, Folder_1, % Folder_1        }    }    Else If ( A_GuiControl = "Browse_2" )    {        Folder_2 := ""        FileSelectFolder, Folder_2, , 2, Select second folder.        If ( ErrorLevel != 1 )        {            GuiControl, Text, Folder_2, % Folder_2        }    }    ; Right justify the edit control's content if longer than the control's length    SendMessage, 0xB1, 500, 500, Edit1 ; 0xB1 is EM_SETSEL    SendMessage, 0xB1, 500, 500, Edit2 ; 0xB1 is EM_SETSEL}Return

lijieliang:
that does the job. thanks a lot.

Navigation

[0] Message Index

[#] Next page

Go to full version