LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 06-03-2011, 07:11 PM   #1
steve51184
Member
 
Registered: Dec 2006
Posts: 372

Rep: Reputation: 30
little help on making batch sfv files


hi I have 2 thing I'm trying to do with .sfv files so I'll start with the first..


the first thing i want to do is to make an .sfv file for ALL files in the current folder into a single .sfv file and this command does it perfectly and even checks if .sfv already exists and skips if it does:

Code:
cfv -C -tsfv
the second is to make an .sfv file for each file in the current folder and save it to it's own .sfv file and the best way i've found to do this so far is this:

Code:
for f in *.rar; do cksfv "$f" > "$f".sfv; done
this command works perfectly but unlike the first it doesn't check if the .sfv already exists so if there's 10 1gb files all with .sfv files already it'll just remake ALL the .sfv files again so as you can imagine it takes up a lot of time

if there a way to make it check if the .sfv already exists first? or possibly do it another better way?

thanks
 
Old 06-03-2011, 09:59 PM   #2
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
How about this?

Code:
for f in *.rar; do [[ -f "${f}.sfv" ]] || cksfv "$f" > "$f".sfv; done
I don't have the cksfv program, so I didn't test this, but I think it does what you want.
 
Old 06-04-2011, 05:06 AM   #3
steve51184
Member
 
Registered: Dec 2006
Posts: 372

Original Poster
Rep: Reputation: 30
perfect thank you!!!
 
Old 06-04-2011, 06:53 AM   #4
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
You're welcome. It is good to know you found my reply helpful.

If this issue has been resolved then please consider using the thread tools to mark this thread solved.
 
Old 06-04-2011, 07:22 AM   #5
steve51184
Member
 
Registered: Dec 2006
Posts: 372

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Telengard View Post
You're welcome. It is good to know you found my reply helpful.

If this issue has been resolved then please consider using the thread tools to mark this thread solved.
i've done that thank you

also if i'm not a bother could you possibly explain what this part of the command does

Code:
[[ -f "${f}.sfv" ]] ||
i'm guessing it looks for the file and if it exists skip the part after || and if it doesn't run the bit after || correct?
 
Old 06-04-2011, 01:03 PM   #6
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by steve51184 View Post
i'm guessing it looks for the file and if it exists skip the part after || and if it doesn't run the bit after || correct?
Yes, that is essentially how it works.
  • [[ opens a Bash conditional construct
  • -f is a Bash conditional expression which tests for the existence of a regular file with the given name and yields a true status if it was found.
  • ${f}.sfv expands to the file name returned by * from the for loop, with the sfv extension appended.
  • || operator causes the next stanza of the command list to be executed only if the previous stanza yielded a false status.

BTW I don't really know the proper name for segments of a command list, so stanza may not be correct.

Last edited by Telengard; 06-04-2011 at 01:10 PM.
 
Old 06-08-2011, 11:46 AM   #7
steve51184
Member
 
Registered: Dec 2006
Posts: 372

Original Poster
Rep: Reputation: 30
Wow thank you
 
  


Reply

Tags
bash, conditional, loop


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a batch shell script to convert, merge and append (join) movie's to mkv mnt_schred Programming 8 12-07-2009 11:51 AM
Batch files to execute and transfer files via sftp cm67 Linux - General 5 08-13-2009 09:59 AM
Making a batch/cron for tar command ? centosfan Linux - Server 2 08-19-2008 04:29 PM
sfv checker phatbastard Linux - Software 0 11-18-2004 12:21 PM
what are .m3u and .sfv files? servnov General 3 09-18-2004 09:36 PM


All times are GMT -5. The time now is 10:42 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration