PowerArchiver Home


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

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 02-04-2009, 11:46 PM
Infina Infina is offline
Senior Members
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Extracting only 1st file in a directory of archives

Hi guys, I have a problem:

I have a list of rar files in a folder, but I would like to have ONLY the 1st file in each rar to be extracted to a folder. The first file is designated by its name, which is not standard/constant throughout all of the rars. Basically, whatever the name is of the first file, I would like it extracted. Is there any way to direct paext to do such a thing? Thanks alot!
Reply With Quote
  #2  
Old 02-05-2009, 05:18 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
There is no "first file" in an archive.

How do you determine which is the "first file" you want to extract - by name (alphabetically) or by date (created, modified or ... ) or by file size (largest, smallest) or some other way?
__________________
Terry

WinXP SP3
Reply With Quote
  #3  
Old 02-05-2009, 07:34 AM
Infina Infina is offline
Senior Members
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
it would be first by name, sorry.
Reply With Quote
  #4  
Old 02-05-2009, 09:31 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
It *may* be possible to create a batch file to do this - but it would be non-trivial, my batch knowledge is not good enough

However, I just realised another problem with your scenario: you stated that these are rar archives. If they have been compressed as "solid" archives, then extracting a single file is not possible anyway, you always have to extract everything from a solid archive.
__________________
Terry

WinXP SP3
Reply With Quote
  #5  
Old 02-05-2009, 09:43 AM
Infina Infina is offline
Senior Members
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I have basic batch scripting experience, but I have been trying. Also, the rar's are not solid, so it can be specified which files to extract.
So far, I have:
1. paext generating a list of the contents of each rar and outputting to a text file.
2. head.bat (a batch that reads in the 1st line from a text file) to send to another text file.
3. paext again to read in the first file name from the previous text file and extract only that file.
4. it does work, but what I need now is to somehow incorporate this process in a for loop so it's done automatically to all rars in a directory

here is my wack-ass code lol:

for /d %%X in (DIR\) do call cc2.bat

[cc2.bat]
c:
cd c:\pacl\
paext -v -d "DIR\*.cbr" | find /i ".jpg" > x:\temp.txt && call x:\head.bat 1 x:\temp.txt > x:\firstfile.txt
paext -px:\temp "DIR" @x:\firstfile.txt
^-output directory

What happens is that it only extracts the 1st file from the 1st archive, i.e. it doesn't go through all of the archives

Last edited by Infina; 02-05-2009 at 09:47 AM.
Reply With Quote
  #6  
Old 02-05-2009, 12:34 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
Isn't [for /d] working with folders and not files?
__________________
Terry

WinXP SP3
Reply With Quote
  #7  
Old 02-05-2009, 01:12 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
I also think you need to sort the list output (just in case) depending on required ouptut.

Something like:-
{For each cbr file call cc2}
for %%X in (DIR\*.CBR) do call cc2.bat %%x

and use passed variable in cc2 -

paext -v %x | sort > x:\temp.txt
call x:\head.bat 1 x:\temp.txt > x:\firstfile.txt
paext -px:\temp %x @x:\firstfile.txt

Not sure what you are using find for??
__________________
Terry

WinXP SP3
Reply With Quote
  #8  
Old 02-05-2009, 02:00 PM
Infina Infina is offline
Senior Members
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
find is to extract only the .jpg's in the output from paext -v, as it gives other info in the output
Reply With Quote
  #9  
Old 03-13-2010, 12:52 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
Old thread I know, but I find the problem described here very interesting.

Quote:
Originally Posted by TBGBe View Post
How do you determine which is the "first file" you want to extract - by name (alphabetically) or by date (created, modified or ... ) or by file size (largest, smallest) or some other way?
Quote:
Originally Posted by Infina View Post
it would be first by name, sorry.
The problem here is that like TBGBe says there are no first file in the archive. Infina, you say that it would be first by name, but the problem is that you don't know which file that will be first in the list, resulting in that the name of the file won't matter if it's always the first file in the file list of the archive.

If the name would be the first name in alphabetical order, then you would have to read the whole file list from the archive and then sort the names in alphabetical order to find the file name that would be the first file in this case.

The next problem is that an archive can have multiple files with same name, but in different folders. If that happens, which file would be the first to extract?

If you always are going to extract the first file that is in the file list of the archive, how do you know that it's the correct file?

Example: first add the file Z-TEXT.txt to Archive Test.zip and then add the file A-TEXT.txt to the same archive.

If I then list the contents of Test.zip the file Z-TEXT.txt will appear first in the list, but how do you know that this is the correct file and not A-TEXT.txt

The functionality you are asking for can be fixed, but not without your definition of "first file".

Kind Regards
Micke
Reply With Quote
  #10  
Old 03-13-2010, 04:26 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
And don't forget the possibility of same name with different file extension e.g. Z.txt, Z.jpg, Z.ini (etc)
__________________
Terry

WinXP SP3
Reply With Quote
Reply

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


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


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