extract 1st file in directories

February 7, 2009 at 12:53:56
Specs: Windows Vista
I've been pulling my hair out for the past couple days, learning dos commands and batch scripting so here's the story:
I have nested directories of .cbr's (rar'd comic files) and I would like to extract ONLY the 1st file in each one (being the cover page of each comic) to a specified folder.

See More: extract 1st file in directories

Report •

February 7, 2009 at 15:28:21
Is there anything unique in the file names like "part 1" or something similar? Also how do you define "specified folder" because you have not specified it here; will each title page go into it's own folder or will they all go into a communal "title page folder"?

Report •

February 7, 2009 at 15:39:17
I'm trying to use the 7z command line and the pics can all go to 1 communal folder. I have no preference. I have code to extract the 1st file names, but no way to tell 7z to extract only those files. Or maybe I'm not understanding the include switch correctly... Here is my code thus far:
for /f "tokens=*" %%a IN ('dir /b "x:\comics\"') do 7z l "x:\comics\%%~nxa" -r -aot | find /i ".jpg" > x:\temp.txt && call x:\head.bat 1 x:\temp.txt >> x:\firstfile.txt

Basically, 7zip accepts the archives' filenames, outputs the list of files in each archive, looks for lines with only ".jpg" then sends it to a temp.txt. Head.bat is a batch that reads the 1st line off a text file, so it reads the first line (being name of 1st file in the archive) and outputs it to firstfile.txt which collects the 1st filenames in each archive. At this point I'm stuck because when I use this file with 7zip, it says there are no files to process. However, a program called PowerArchiver can read this file, but can't use it to unzip 7z files. sigh

Report •

Related Solutions

Ask Question