Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: delet (.rar .zip ) files after successfully unzip  (Read 18518 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    delet (.rar .zip ) files after successfully unzip
    « on: May 29, 2009, 03:55:36 AM »
    how  can  we be sure that  (.rar .zip ) files are unziped  successfully  and delet them?
    i  need some scripts  in  batch file format  that check  to  see if extraction  is complete successfully   then  delet (.zip .rar) files
    is there any  way  to  help?
    by  the way
    1- i have winrar installed  in  my  system
    2-  broken (.zip .rar) files should be ignored of deletion
    thanks

    Reno



      Hopeful
    • Thanked: 32
      Re: delet (.rar .zip ) files after successfully unzip
      « Reply #1 on: May 29, 2009, 04:28:15 AM »
      i think i've this kind of script that i use in the past:

      here it is:
      _unrar.bat
      Code: [Select]
      @echo off

      for /f "tokens=*" %%a in ('dir /b *.rar *.zip') do (
      %%~xa e -y "%%~a" && attrib +h "%%~a"
      )

      pause

      and _clean.bat
      Code: [Select]
      @echo off

      for /f "tokens=*" %%a in ('dir/b/ah *.zip *.rar') do (
      for /f "tokens=*" %%b in ('%%~xa lb "%%a"') do (
      dir/b "%%b" >nul 2>&1 && (del/a "%%a" && echo DELETE: %%a)
      )
      )

      i use the rar.exe and 7zip.exe (the command line version). copy both files to the same folder as the .bat files, and rename it to '.rar.exe' and '.zip.exe'

      how _unrar works:
      1. it extract the files, prompt for password if any, on successful, it hide the file (treating the hidden file(s) as recycle bin)

      how _clean works: (cleaning the "recycle bin")
      it check for hidden rar zip files, then list the content, and check if the content is already extracted, once it sure, it then delete the rar zip file for good.

      mioo_sara

        Topic Starter


        Intermediate

        Re: delet (.rar .zip ) files after successfully unzip
        « Reply #2 on: May 29, 2009, 07:05:04 AM »
        dear reno i tried your scripts but i have error message

        Quote
        '.rar' is not recognized as an internal or external command,
        operable program or batch file.
        Press any key to continue . . .


        i  even  found ( rar.exe and 7z.exe ) and copied them  in folder next to  my.bat file but it can't extract or even  find my  (.zip .rar ) files !!
        rar.exe path  that i  found =C:\Program Files\WinRAR\Rar.exe
        7z.exe= i download it


        but  i  tried another script that can  perfectly  extract  my  (.zip  and .rar ) files

        Quote
        @echo OFF
        for %%f in (*.zip *.rar) do "C:\Program Files\WinRAR\Winrar.exe" x "%%f"
        it does not need me to  copy  anything ..but there is a problem  that i mentioned before in  my  post number 1

        how can  i  be sure that (.zip and .rar ) files have been  extracted 100% successfully?  and then  delet (.zip and .rar ) files?
        and how to  ignore broken  files and those files that has not been  extracted successfully from  deletion?

        thanks

        devcom



          Apprentice

          Thanked: 37
          Re: delet (.rar .zip ) files after successfully unzip
          « Reply #3 on: May 29, 2009, 07:30:51 AM »
          you need to use for loop and findstr to filter output

          Code: [Select]
          C:\CMD>rar x GETIP |findstr "Wypakowuję"

          Wypakowuję  GETIP.exe                                                 OK


          Code: [Select]
                  1             2                                                         3
          Wypakowuję  GETIP.exe                                                 OK

          then you need to match 3 token
          Download: Choice.exe

          mioo_sara

            Topic Starter


            Intermediate

            Re: delet (.rar .zip ) files after successfully unzip
            « Reply #4 on: May 29, 2009, 08:59:55 AM »
            devcom
            what are those codes?
             should i type them  in  CMD?
            i  need batch  codes
            can  you  help with  that?

            Reno



              Hopeful
            • Thanked: 32
              Re: delet (.rar .zip ) files after successfully unzip
              « Reply #5 on: May 29, 2009, 09:48:45 AM »
              i  even  found ( rar.exe and 7z.exe ) and copied them  in folder next to  my.bat file but it can't extract or even  find my  (.zip .rar ) files !!
              rar.exe path  that i  found =C:\Program Files\WinRAR\Rar.exe
              7z.exe= i download it


              Answer:
              i use the rar.exe and 7zip.exe (the command line version). copy both files to the same folder as the .bat files, and rename it to '.rar.exe' and '.zip.exe'
              you miss this important step, rename rar.exe to '.rar.exe' and '7z.exe' to '.zip.exe', are you sure 7z.exe is the command-line version?

              mioo_sara

                Topic Starter


                Intermediate

                Re: delet (.rar .zip ) files after successfully unzip
                « Reply #6 on: May 29, 2009, 10:15:38 AM »
                Quote
                you miss this important step, rename rar.exe to '.rar.exe' and '7z.exe' to '.zip.exe',
                dear reno
                i did not missed it ! i  just did not report it back 
                first  in  windows xp  unfortunately we can't add (.) to  first part of files names i tried to  rename rar.exe to .rar.exe  but i  have a error report that windows is  unable to  rename it to  .rar.exe i even  tried to  rename it  to '.rar.exe' but you  can  guess what happened
                Quote
                are you sure 7z.exe is the command-line version?

                well  i  am  sure  but what  about  (*.rar ) files?
                why it can't even  extract them? i  copied rar.exe and myfile.rar and my.bat ito  a folder and start my.bat but  i  have still  that error message
                what should  i  do?
                what  about  that scripts  that  i  mentioned ?  that is working  perfectly
                cant  you  fix that or find another way?

                Reno



                  Hopeful
                • Thanked: 32
                  Re: delet (.rar .zip ) files after successfully unzip
                  « Reply #7 on: May 29, 2009, 10:28:23 AM »
                  it working fine here, except i am doing it in command line
                  ren rar.exe .rar.exe

                  as for the modification the script you mentioned:
                  @echo OFF
                  for %%f in (*.rar) do "C:\Program Files\WinRAR\rar.exe" e "%%f" && del "%%f"

                  the same to do wit the zip file

                  TheHoFL



                    Intermediate

                    Thanked: 5
                    Re: delet (.rar .zip ) files after successfully unzip
                    « Reply #8 on: May 29, 2009, 10:41:28 AM »
                    Are you looking to have the RAR extract and then immediately delete or to have a directory scanned and delete the RAR files that have been extracted?
                    All your dreams can come true if you have the courage to pursue them.  - Walt Disney

                    mioo_sara

                      Topic Starter


                      Intermediate

                      Re: delet (.rar .zip ) files after successfully unzip
                      « Reply #9 on: May 29, 2009, 02:28:01 PM »
                      well  first of all  thanks for helping me reno
                      i  think  with  your help  at last  i reached somewhere
                      ========================================

                      i  tried to  replace your script with  below script
                      Quote
                      @echo OFF
                      for %%f in (*.zip *.rar) do "C:\Program Files\WinRAR\Winrar.exe" x "%%f" && del "%%f"

                      it can  now extract any ( zip  or rar) files and then  delet the source files and if found broken  or password protected file ignore it from  deletion
                      but i know that this program  can  now work  just under winxp with  winrar istalled
                      i  have  some question=
                      1-  how is it possible to  rename rar.exe to .rar.exe ? windows xp  does not allow  to  put (.) at the  first character of files
                      is it some kind of trick  that i am  not aware of?
                      2-  what is that  (.) doing?  is it that  important?
                      3-  you  put (e) in  your script (rar.exe" e ")  but i replace it to  x(means any  file) what is that (e) ?
                      by  the way  i am  using windows xp sp2 and i have winrar 3.80  installed on  my  system
                      i  found rar.exe in  winrar folder with 315 kb size and 7zip(renamed to zip.exe) with 144 kb
                      are the size different from  yours?
                      is it possible to  upload both  your files?
                      thanks

                      mioo_sara

                        Topic Starter


                        Intermediate

                        Re: delet (.rar .zip ) files after successfully unzip
                        « Reply #10 on: May 29, 2009, 02:29:05 PM »
                        dear TheHoFL
                        i  want to  extrat  zip  and rar files and then  delet  zip  and rar files that have been  completely  extracted and keep  the others that are broken  or password protected

                        Reno



                          Hopeful
                        • Thanked: 32
                          Re: delet (.rar .zip ) files after successfully unzip
                          « Reply #11 on: May 31, 2009, 10:50:59 PM »
                          1-  how is it possible to  rename rar.exe to .rar.exe ? windows xp  does not allow  to  put (.) at the  first character of files
                          is it some kind of trick  that i am  not aware of?
                          2-  what is that  (.) doing?  is it that  important?
                          3-  you  put (e) in  your script (rar.exe" e ")  but i replace it to  x(means any  file) what is that (e) ?

                          1. i already told you how to do it, see above, ren rar.exe .rar.exe
                          2. it just to make the batch shorter, the code parse the extension which is .rar and .zip, that's why i rename the exe to .rar.exe and .zip.exe
                          3. type rar.exe /? to find out

                          mioo_sara

                            Topic Starter


                            Intermediate

                            Re: delet (.rar .zip ) files after successfully unzip
                            « Reply #12 on: June 01, 2009, 06:32:02 AM »
                            at last i did it reno !! thanks man 
                            with  your help  i  renamed those files ..but you  should have told me to  do  this through  a .bat file !! i  was renaming  rar.exe and 7zip.exe with  windows xp !! but i  tried this command in  a batch  file
                            ren rar.exe .rar.exe
                            ren 7zip.exe .zip.exe
                            and its done !!!
                            but now there is still  one problem
                            it always remains one file (zip file) undeleted after extraction why?

                            Reno



                              Hopeful
                            • Thanked: 32
                              Re: delet (.rar .zip ) files after successfully unzip
                              « Reply #13 on: June 01, 2009, 08:31:57 AM »
                              it always remains one file (zip file) undeleted after extraction why?

                              what is your code? in what condition the zip file is not deleted?

                              mioo_sara

                                Topic Starter


                                Intermediate

                                Re: delet (.rar .zip ) files after successfully unzip
                                « Reply #14 on: June 02, 2009, 10:26:15 AM »
                                sorry for late
                                Quote
                                what is your code? in what condition the zip file is not deleted?

                                well  i used your(reno) scripts in  post #2
                                i create 3 new folders and compressed them  to  following names
                                New Folder.rar
                                New Folder (2).zip
                                New Folder (3).rar


                                then  copied ( .rar.exe .zip.exe and reno.bat ( your batch  program file) )

                                now i execute it
                                it extract  one folder just New Folder (2).zip and never any of others
                                why? whats wrong? it can  extract zip  file  so  it could not be because of my  .zip.exe , right?
                                as i mentioned before i have winrar 3.80  installed and my  (.rar.exe .zip.exe) size is below
                                .rar.exe === 315kb
                                .zip.exe === 146kb
                                i found rar.exe in  winrar folder

                                thanks