help making batch putting part of filename in text file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
e2678a
Posts: 1
Joined: 06 Jun 2011 23:07

help making batch putting part of filename in text file

#1 Post by e2678a » 06 Jun 2011 23:24

trying to create batch to make multiple nfo files for some tv shows episodes that wont scrape with media scrapers.
its been a while since ive done anything with batch files
wanting to take a tvshow 1x01 episodename.avi file and making nfo or txt with same name and containing


<episodedetails>
<season>1</season>
<episode>1</episode>
</episodedetails>


trying to make multiple episodes.
all ive been able to figure out to do is create empty nfo files with sames of shows.
not even sure if possible with batch file.
any help would be greatly appreciated.

while searching found a bash file that looks like what im trying to do

I need to create nfo like this:


<episodedetails>
<title>tvshow</title>
<episode>10</episode>
<season>1</season>
</episodedetails>
File is tvshow - 1x10 -episodename.mkv

I don't need 'tvshow' part with the NFO, but everything else. I tried google, but without any luck. Script almost works for me, but I don't know how to use sed to ignore the 'tvshow' and split 1x10 to episode and season.

Try something like:

#!/usr/bin/env bash

while IFS= read -rd '' file; do

filename="${file##*/}"

title="${filename%\.mkv}"
title="${title##* - }"

episode="${filename#* - *x}"
episode="${episode% - *.mkv}"

season="${filename#* - }"
season="${season%x* - *.mkv}"

cat > "${file%\.mkv}.nfo" <<< \
"<episodedetails>
<title>${title}</title>
<episode>${episode}</episode>
<season>${season}</season>
</episodedetails>"

done < <(find . -name '*.mkv' -print0)



thanks

Post Reply