PowerArchiver Home


Go Back   PowerArchiver Forums > PowerArchiver Command Line (PACL) > Tech Support

Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-15-2010, 11:56 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Batch File to compress multiple file types

I had an old batch file that used winzip that I am trying to convert over to use PACL.

What it should do
: Pulls all of the listed types of media files from a CD, including all subdirectories and preserving pathnames. Creates a .zip archive of all of them and outputs a log file.
The batch file takes 2 arguments: the name of the archive to create and the letter of the CD-Drive that has the CD in it.

When I run the Batch file as "makepzip ta0000 e" this is the output from the log:

Archive: d:\ta0000.zip
preparing to compress...
*** WARNING: Nothing to add or update...

All OK


So, it looks like either it is not going into all the subdirectories on the CD, or it is only checking the first filetype (jpg), because I know that there are .gif files in some of the directories.

Here are the commands in my Batch file:

@ECHO OFF
ECHO ** This batch file will find all Media Files on %2 and create a zip **
ECHO ** file called d:\%1.zip and d:\%1.log **
"c:\apps\PACOMP" -a -r -P d:\%1.zip %2:\*.jpg %2:\*.bmp %2:\*.gif %2:\*.jpeg %2:\*.tif
%2:\*.tiff %2:\*.mpg %2:\*.mpeg %2:\*.mov %2:\*.rm %2:\*.ram %2:\*.asf %2:\*.wmv %2:\*.mpe
%2:\*.avi %2:\*.jfif %2:\*.jif %2:\*.art %2:\*.jpe %2:\*.png %2:\*.vob %2:\*.3gp %2:\*.mpa
%2:\*.tmp %2:\*.3g2 %2:\*.asx %2:\*.flv %2:\*.shs %2:\*.m2v %2:\*.mod %2:\*.cjp %2:\*.divx
%2:\*.wm %2:\*.dv %2:\*.mp4 > d:\%1.log


Any help you can give me would be greatly appreciated. Thanks!

Dustin
  #2  
Old 02-15-2010, 03:08 PM
TBGBe's Avatar
TBGBe TBGBe is offline
Still Mainly Lurking
 
Join Date: Jul 2001
Location: UK
Posts: 2,151
Thanks: 6
Thanked 102 Times in 94 Posts
Two thoughts - but not much help, I'm afraid.

a) I believe there is a 255 char limit on the command
b) It appears that the -r command does not work when a filetype is specified (i.e. works only with *.*)

Will have to wait for Spwolf or Milli to confirm / deny.

P.S. I did a quick test with PACL 6.01 on XP SP3
__________________
Terry

WinXP SP3
  #3  
Old 02-15-2010, 03:20 PM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hmm, didn't think about the character limit, although it does get all the way through the command and create the log file. I am using 6.01 with WinXP SP3 as well.

I guess I could execute a separate command to add each file type to the archive, but I was hoping there was a more efficient way of doing it.
  #4  
Old 02-16-2010, 08:21 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
I did some more testing, using multiple instances of the command, can definitely say that it is not recursing the subdirectories. Anyone see a syntax error in the command I'm using?

"c:\apps\PACOMP" -a -r -P d:\%1.zip %2:\*.inf >> d:\%1.log
  #5  
Old 02-16-2010, 08:24 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Guess I should add that passing in the arguments and using them in the commands is working fine. There was a .inf file in the root, and it successfully added it to the archive and sent the log to the file.
  #6  
Old 02-16-2010, 11:04 AM
spwolf's Avatar
spwolf spwolf is offline
Administrator
 
Join Date: Jun 2001
Posts: 7,823
Thanks: 682
Thanked 207 Times in 192 Posts
didnt have time yet to look, will do a bit later on, thanks for the patience!
__________________
ConeXware, Inc.
latest PA release info on Facebook, Twitter | Follow us and win free PowerArchiver.
  #7  
Old 02-22-2010, 09:53 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hi spwolf, have you had a chance to look at this issue yet?

Thanks!
  #8  
Old 02-22-2010, 09:55 AM
spwolf's Avatar
spwolf spwolf is offline
Administrator
 
Join Date: Jun 2001
Posts: 7,823
Thanks: 682
Thanked 207 Times in 192 Posts
i have an feeling recurse subfolder option does not work unless it gets *.*, which is where the problem would be then... i have sent it to dev team to investigate.
__________________
ConeXware, Inc.
latest PA release info on Facebook, Twitter | Follow us and win free PowerArchiver.
  #9  
Old 02-22-2010, 09:57 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hmm, ok, thanks!
  #10  
Old 02-26-2010, 03:58 PM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Hi Dustin!

Quote:
Originally Posted by DHaralson View Post
Any help you can give me would be greatly appreciated. Thanks!

Dustin
You can get the function you are looking for by using a small vbscript that will loop through the folders looking for the specified fileextensions. This is a workaround for the problem that filename like *.jpg won't work when using the recursive parameter.

The script is this:
Code:
'***********************************************************
'* PACOMP.vbs
'* @author: Micke
'*
'* Script for compress multiple file types
'*
'* Usage: cscript PACOMP.vbs ArhiveName.extension DrivePath
'* Example1: cscript PACOMP.vbs MyArchive.zip D:
'* Example2: cscript PACOMP.vbs MyArchive.zip D:\Temp
'*
'***********************************************************
Option Explicit

'Variables
Dim FSO, objDir, aList, FileExtension, ArchiveName, DrivePath
Dim aFile, aItem, strCompressionString, WshShell

'Constants (Change path to your own enviroment)
Const PACOMP = "C:\Programs\PACL\PACOMP.exe"

'Check number of arguments
If WScript.Arguments.Count <> 2 Then
	WScript.Echo "Usage: cscript PACOMP.vbs ArchiveName.extension DrivePath"
	WScript.Echo "Example 1: cscript PACOMP.vbs MyArchive.zip D:"
	WScript.Echo "Example 2: cscript PACOMP.vbs MyArchive.zip D:\Temp"
	WScript.Quit
End If

'Create the FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")

'Create the ShellObject
Set WshShell = CreateObject("WScript.Shell")

'Get data from the Arguments
ArchiveName = WScript.Arguments.Item(0)
DrivePath = WScript.Arguments.Item(1)

'Get the Folders for the DrivePath
Set objDir = FSO.GetFolder(DrivePath)

'Create a Array with Fileextensions for the archive, change to your enviroment
aList = Array("png", "jpg", "avi")

'Search through the folders
SearchFolders(objDir)

'Sub for Searching recursive in Folders
Sub SearchFolders(pstrCurrentPath)
	
	For Each aFile In pstrCurrentPath.Files
		
		For Each FileExtension In aList
			If FileExtension = LCase(Right(CStr(aFile.Name), 3)) Then
				AddFileToArchive aFile.Path
			End If
		Next
		
	Next
	
	For Each aItem In pstrCurrentPath.SubFolders
	   SearchFolders(aItem)
	Next

End Sub

Sub AddFileToArchive(pstrFileName)
	
	'Create the string with parameters for PACOMP
	strCompressionString = PACOMP & " -a -P " & ArchiveName & " " & pstrFileName
	WScript.Echo strCompressionString
	WshShell.Run strCompressionString, 0, True
	
End Sub
You can also downloading the script here: PACOMP_Script.zip

There are two lines in the script you have to modify for your own enviroment.

Change this to your path for PACOMP
Code:
Const PACOMP = "C:\Programs\PACL\PACOMP.exe"
Add more FileExtension for your Archive. I have tested it with these 3 and it works as expected.
Code:
aList = Array("png", "jpg", "avi")
The script is only tested on Windows XP with SP3. Hope that it will work for you.

Kind Regards
Micke
The Following User Says Thank You to Micke For This Useful Post:
spwolf (02-26-2010)
  #11  
Old 02-28-2010, 09:00 AM
TBGBe's Avatar
TBGBe TBGBe is offline
Still Mainly Lurking
 
Join Date: Jul 2001
Location: UK
Posts: 2,151
Thanks: 6
Thanked 102 Times in 94 Posts
Micke,
When I tried it -

I changed the path to PACOMP and the extension array to (jpg, png, txt).

Each "expected" command line was echoed, but no archive file was created

Then I tried full path ( c:\multypes.zip ) for "my archive" but other than that my script understanding is very limited.

What did I miss?
__________________
Terry

WinXP SP3
  #12  
Old 02-28-2010, 11:14 AM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Quote:
Originally Posted by TBGBe View Post
Micke,
When I tried it -

I changed the path to PACOMP and the extension array to (jpg, png, txt).
Did you put a " around each fileextension in the Array? Like ("jpg", "png", "txt")

Quote:
Each "expected" command line was echoed, but no archive file was created

Then I tried full path ( c:\multypes.zip ) for "my archive" but other than that my script understanding is very limited.

What did I miss?
How is your command written in the CMD Window when you are running the script? If I can see your command I can then see if something is missing.

Kind Regards
Micke
  #13  
Old 02-28-2010, 05:24 PM
TBGBe's Avatar
TBGBe TBGBe is offline
Still Mainly Lurking
 
Join Date: Jul 2001
Location: UK
Posts: 2,151
Thanks: 6
Thanked 102 Times in 94 Posts
Quote:
Originally Posted by Micke View Post
Did you put a " around each fileextension in the Array? Like ("jpg", "png", "txt")
Quote:
Originally Posted by PACOMP.vbs
'Create a Array with Fileextensions for the archive, change to your enviroment
aList = Array("png", "jpg", "txt")
Quote:
Originally Posted by Micke View Post
How is your command written in the CMD Window when you are running the script? If I can see your command I can then see if something is missing.
...
Try to change the archive name from c:\multypes.zip to c:\temp\multypes.zip
See attached screenshot
The c:\temp folder is empty.
Thanks for getting back so quick.

P.S. I am admin on WinXP SP3

P.P.S. Just thought - should the output path/filename to add be in quotes ??
Attached Images
 
__________________
Terry

WinXP SP3
The Following User Says Thank You to TBGBe For This Useful Post:
spwolf (03-01-2010)
  #14  
Old 03-01-2010, 05:43 AM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Hi!

Quote:
Originally Posted by TBGBe View Post
P.P.S. Just thought - should the output path/filename to add be in quotes ??
That's correct. I have made some more tests and the problem appears when you have spaces in the path and/or in the filename. That's my mistake , because when I tested the script I didn't have any spaces in the path or in the filename resulting in that everything looked ok.

Here's the updated script with support for spaces in path or filename.

Code:
'*******************************************************************
'* PACOMP.vbs
'* @author: Micke
'* @hist 2010-02-26	CREATED:Script for compress multiple file types
'* @hist 2010-03-01 BUGFIX:	Space in path or filename resulted in
'*							no archive was created.
'*
'* Script for compress multiple file types
'*
'* Usage: cscript PACOMP.vbs ArchiveName.extension DrivePath
'* Example1: cscript PACOMP.vbs C:\Temp\MyArchive.zip D:
'* Example2: cscript PACOMP.vbs C:\Temp\MyArchive.zip D:\Temp
'*
'*******************************************************************
Option Explicit

'Variables
Dim FSO, objDir, aList, FileExtension, ArchiveName, DrivePath
Dim aFile, aItem, strCompressionString, WshShell

'Constants (Change path to your own enviroment)
Const PACOMP = "C:\Programs\PACL\PACOMP.exe"

'Check number of arguments
If WScript.Arguments.Count <> 2 Then
	WScript.Echo "Usage: cscript PACOMP.vbs ArchiveName.extension DrivePath"
	WScript.Echo "Example 1: cscript PACOMP.vbs C:\Temp\MyArchive.zip D:"
	WScript.Echo "Example 2: cscript PACOMP.vbs C:\Temp\MyArchive.zip D:\Temp"
	WScript.Quit
End If

'Create the FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")

'Create the ShellObject
Set WshShell = CreateObject("WScript.Shell")

'Get data from the Arguments
ArchiveName = WScript.Arguments.Item(0)
DrivePath = WScript.Arguments.Item(1)

'Get the Folders for the DrivePath
Set objDir = FSO.GetFolder(DrivePath)

'Create a Array with Fileextensions for the archive, change to your enviroment
aList = Array("png", "jpg", "avi")

'Search through the folders
SearchFolders(objDir)

'Sub for Searching recursive in Folders
Sub SearchFolders(pstrCurrentPath)
	
	For Each aFile In pstrCurrentPath.Files
		
		For Each FileExtension In aList
			If FileExtension = LCase(Right(CStr(aFile.Name), 3)) Then
				AddFileToArchive aFile.Path
			End If
		Next
		
	Next
	
	For Each aItem In pstrCurrentPath.SubFolders
	   SearchFolders(aItem)
	Next

End Sub

Sub AddFileToArchive(pstrFileName)
	
	'Create the string with parameters for PACOMP
	strCompressionString = PACOMP & " -a -P " & Chr(34) & ArchiveName & Chr(34) & " " & Chr(34) & pstrFileName & Chr(34)
	WScript.Echo strCompressionString
	WshShell.Run strCompressionString, 0, True
	
End Sub
The updated script can be downloaded here: PACOMP_Script_Updated.zip

Please let me know the result after you have tested the updated script.

Kind Regards
Micke
The Following User Says Thank You to Micke For This Useful Post:
spwolf (03-01-2010)
  #15  
Old 02-28-2010, 11:19 AM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Quote:
Originally Posted by TBGBe View Post
Then I tried full path ( c:\multypes.zip ) for "my archive" but other than that my script understanding is very limited.

What did I miss?
There could be a privilege problem. If you are logged on as a non administrator user in Windows XP, you don't have write access to the root of c:\

Try to change the archive name from c:\multypes.zip to c:\temp\multypes.zip

Kind Regards
Micke
  #16  
Old 03-01-2010, 01:41 PM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Thanks, nice to hear that it's working for you now.

Kind Regards
Micke
  #17  
Old 03-01-2010, 02:07 PM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Wow, thanks for helping out with that script Micke! I'll give it a try.

Thanks,
Dustin
  #18  
Old 03-09-2010, 03:28 AM
Micke's Avatar
Micke Micke is offline
PA Super User
 
Join Date: Feb 2010
Location: Sweden
Posts: 131
Thanks: 11
Thanked 52 Times in 40 Posts
Hi Dustin!
Have you tested the script and if so, is it working correctly for you?

Kind Regards
Micke
  #19  
Old 03-09-2010, 09:05 AM
DHaralson DHaralson is offline
Senior Members
 
Join Date: Feb 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, your script works. Thanks for all the help!
Closed Thread

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to unzip file to desirable destination with batch file? BirgemBorg Tech Support 2 01-12-2009 11:15 AM
compress one file into multiple parts kpb Wishlist 2 10-16-2008 09:36 AM
File types for extact and archive smerey General 2 04-13-2006 07:58 AM
Master file types should be backed up! nameless Wishlist 1 07-17-2004 10:51 AM


All times are GMT -5. The time now is 12:48 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.