Super Star Book Compression Special Script Project

zhaozj2021-02-16  84

Although the quality of the SARB is not high, it is relatively new, more complete, so it is worth seeing.

However, each page of the super star book is a separate file, very small, far less than the current hard disk cluster size, causing great space waste, while copying the mobile file, due to a large number of files, copy Or moving speed is also very slow.

A preferred method is to compress all the page files of the SARB book into a file. When reading, then the hard disk space is wasting, and the copy time is also improved.

However, if there is a lot of super star books, you must press Right Press on the directory on the directory, then select compression, and the efficiency is too low. Therefore, I have written a script with the Windows Script scripting language to automatically compress each book catalog under the specified directory into separate compressed files.

If it is performed under the command line window, you can use

Cscript compress.js to compress the directory

In this way, the progress information of the operation can be output. If you click Compress.js directly, you will pop up the prompt window, which affects it.

At the same time, you need to set the compressed software of the compressed usage in the path PATH environment parameters. I use two compression software, one is pkzip25, which is a 32-bit command line ZIP compression, and WinRar command line version, RAR .exe, the script corresponding to these two compression programs is as follows:

Use pkzip25.exe's compress.js

VAR fs = new activ = "scripting.filesystemObject"); var s = wscript.createObject ("wscript.shell"); var arg = wscript.Arguments;

// Take the directory IF to be processed (arg.count ()) {var f = fs.getFolder (arg.item (0));} else {var f = fs.getfolder (".")};

// Get all directories in the specified directory VAR fc = new enumerator (f.subfolders); for (;! Fc.atend (); fc.movenext ()) {var ff = fs.getFolder (fc.Item () ); Var fname = ff.name; wscript.echo ("is compressed" '"' fname '"); s.run ("pkzip25.exe -add -directories -move -recurse /" fname " / "/"" fc.Item() "/" ,7,2rue; wscript.echo ('" "' fname '"' "Compressed");}} Note: PKZIP25 compressed command line parameters Is -Add Add File to Compressed Document -Move Remove Source File -Directories Save Directory Structure, use relative path -Recurse recursive processes

Use rar.exe's compress.js

VAR fs = new activityXObject ("scripting.filesystemObject"); var s = wscript.createObject ("wscript.shell"); var arg = wscript.Arguments; // acquire the directory IF to be processed (arg.count ()) { VAR f = fs.getFolder (arg.item (0));} else {var f = fs.getfolder (".")};

// Get all directories in the specified directory VAR fc = new enumerator (f.subfolders); for (;! Fc.atend (); fc.movenext ()) {var ff = fs.getFolder (fc.Item () ); Var fname = ff.name; wscript.echo ("is compressed" '"' fname '"); s.Run ("RAR M -R /" FNAME "/" / " fc .Item () "/", 7, true); wscript.echo ('""' fname '"' " Compression ");}} Note: RAR's compressed command line parameters are M mobile files to compressed files - Save the directory structure, use the relative path, and recursively processed subdirectory

note:

1. Be sure to execute with CScript.exe on the command line, otherwise the prompt window 2 will continue to pop up, set the path to the RAR and PKZIP25 in the PATH environment variable.

转载请注明原文地址:https://www.9cbs.com/read-12444.html

New Post(0)