Archive content listing

Discuss and share scripts and script files...
Post Reply
totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Archive content listing

Post by totmad1 »

While trawling the net came across this batch file.

Code: Select all

FOR /F "tokens=* delims=" %%A in ('dir /b /s *.rar ; *.7z ; *.cab ; *.gz ; *.zip') do ("C:\Users\user\Documents\portaprogs\7-ZipPortable\App\7-Zip64\7z.exe" l -r "%%A" >> listingALL.txt)
I have altered it slightly to include formats that I have bumped into. There are more formats which 7-zip will list.
This will also, with a little adjustment, work with IZArc2Go .

I of course cant leave anything alone so this is my attempt in XY scripting.

If you are going for depth then :- open find files
make sure your in the right folder to find your archives change "All types" to "Archive files" run search
select all and run this

Code: Select all

 Writefile ("<curfolder>.txt", getinfo("SelectedItemsPathNames"), o);
I have this on the toolbar to give me a reminder.
"Archive LIST Single && this folder && to depth ->" msg "select one item first<br>if doing to depth then<br>make sure path(s) do not contain<br>commas,spaces or dots"; load (7zlisting);
What follows is 7zlisting.xys

Code: Select all

"_Initialize";
        perm $p_zip = "C:\Users\user\Documents\portaprogs\7-ZipPortable\App\7-Zip64\7z.exe";
	perm $p_note = "C:\Users\user\Documents\portaprogs\SynWrite\Syn.exe";
"listing single"
	   Run("cmd /c $p_zip l <curitem> > <curitem>.txt");
"list 1 and open txt"
         Run("cmd /c $p_zip l <curitem> > <curitem>.txt");
         wait 1000; 
           open  "<curitem>.txt";
"listing all in this folder"
        selfilter "*.rar ; *.7z ; *.cab ; *.gz ; *.zip";
       $SelectedItems = get("SelectedItemsNames", "|");
   foreach($Item, $SelectedItems, "|") {
       rename s, " /";   // removes the spaces 
       Run("cmd /c $p_zip l $Item >> <curfolder>.txt");
         wait 1000;
          }
"To Depth:select txtList and list(txtList:- files in subfolders)"
       $a = readfile("<curitem>");   
	   foreach($Item, $a, "<crlf>") {
         Run("cmd /c $p_zip l $Item >> <curfolder>.txt");
         wait 1000;
          }
-

"Edit script : edit"
    $ScriptFile= self ("file");
	    run "$p_note" $ScriptFile,w;
-
"Cancel"
"_Terminate";
       unset $p_zip;
	unset $p_note;
Hope you find useful
totmad1 (totally mad one)
totmad1 (totally mad one)

admin
Site Admin
Posts: 66292
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Archive content listing

Post by admin »

Not mad, uh, bad! :biggrin:

Are you a fast learner, or have been lurking for years?

Welcome to the club,
Don

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Archive content listing

Post by totmad1 »

@ Don
I am afraid to say but was introduced to computers about 43 years ago . First taught myself Fortran from an engineers diary . So can't exactly call myself
a fast learner. Never found trouble learning anything. :oops:

Most code found elsewhere in forum.

As I have already stated can't leave things alone. Had a rethink about spaces and dots in paths.

Code: Select all

"To Depth:select files then run this to make list"

       $path_name = get("SelectedItemsPathNames", "|");
                 $Count=1;
         while(1){
         $file=gettoken($path_name,$Count,"|");
         if("$file"==""){break;}
         $Count++;}
           $i = 1;  $newfile="";
                  while ($i < $Count) {
                  $file=gettoken($path_name,$i,"|");
                    $file = """$file""";
                    $newfile = $newfile . $file . "|";
                    $i++;
                    }
            foreach($Item, $newfile, "|") {
         Run("cmd /c $p_zip l $Item >> <curfolder>List.txt");
         wait 1000;
                }
This has been fully tested on paths and filenames (combined) no problems found .
wish could find way to do subfolder search via scripting . If anyone can point to this will be much appreciated.

totmad1 (totally mad one)
totmad1 (totally mad one)

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

do something for each sub-folder recursive

Post by Stefan »

totmad1 wrote:wish could find way to do subfolder search via scripting .
If anyone can point to this will be much appreciated.
One way would be to utilize folderreport() to get a list of sub folders.
And then use foreach() to iterate across each folder.


Example:

Code: Select all

   $ListOfFolders = folderreport("dirs", "r", , "r" );

   $OUT = "";
   foreach($Folder, $ListOfFolders, "<crlf>"){

        //Example use: do something for each sub-folder recursive:
        $TMP = listfolder($Folder, , , "<crlf>"); 
        if($TMP!=""){$OUT = $OUT . $TMP .  "<crlf>";}

   }
   text $OUT;
Maybe there is a newer way to do this?

 

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Archive content listing

Post by totmad1 »

within half hour of posting thought why not do a search through the help file looking for subfolder
and found folderreport. :lol:
Couldn't figure out files:template so eventually worked out this method.

Code: Select all

"To Depth:select files then run this to make list"
          $Allpath_name = folderreport("files", "r", , "r", , "|");
                 $Count=1;
         while(1){
         $file=gettoken($Allpath_name,$Count,"|");
         if("$file"==""){break;}
         $Count++;
         }
          $i = 1;  $newfile="";
                  while ($i <  $Count+1) {
                  $file=gettoken($Allpath_name,$i,"|");
                    $q = getpathcomponent( "$file", "base");
                    $ext= getpathcomponent( "$file", "ext");
               if ( $ext == "7z" OR $ext == "cab" OR $ext == "gz" OR $ext == "rar" OR $ext == "zip" ) {
                    $file = """$file""";
                    $newfile = $newfile . $file . "|";
                    $i++;
                    }
               else {
                    $i++;
                    }  }
            foreach($Item, $newfile, "|") {
         Run("cmd /c $p_zip l $Item >> <curfolder>List.txt");
         wait 1000;
                }
totmad1 (totally mad one)
totmad1 (totally mad one)

Post Reply