Batch file guru needed.
#1
I have a text file exported from the movie collectorz program and I want to add my DVD collection through stub files. I found this code and modified it to give me the files.


Code:
for /f "tokens=*" %%l in (aaa.txt) do echo %%l > "%%l.dvd.disc"

now Im realizing I want to create a directory named from the list and place the created file into that directory. also I want to add the xml into the file -

Code:
<discstub>
  <message>%moviename% is located in the DVD rack</message>
</discstub>





where "moviename" is taken from the aaa.txt file this is way beyond my tiny brains ability so I need help....LMAO

the text file looks like this...

The Adjustment Bureau (2010)
Alien (1979)
Aliens (1986)
Alien³ (1992)
Alien:_Resurrection (1997)
Alien Vs. Predator (2004)
Aliens Vs Predator - Requiem (2007)
Apollo 18 (2011)
Avatar (Extended_Cut) (2010)
Back To The Future (1985)
Back To The Future II (1989)
Back To The Future III (1990)


and I want to end up with...


a Dir named "The Adjustment Bureau (2010)" with a file named "The Adjustment Bureau (2010).DVD.Disc" in it and the file to contain the xml code from above with "The Adjustment Bureau (2010)" as the moviename.


I have spent hours trying different things and all have failed (and failed well I might add...LOL) I have almost 3,000 DVDS and would hate to have to do this by hand. and I'm sure others could use something similar

is a bat file the best thing to use? would vbs be better? anyone know of a program that will do this? any help or thoughts welcome.
Reply
#2
Use two batch files. Create a batch file called CreateStub.bat that does something like:

Code:
rem %1 is the movie name e.g. "The Adjustment Bureau (2010)"
md "%1"
echo ^<discstub^> >"%1.DVD.disk
echo ^<message^>%1 is located in the DVD rack^</message^> >>"%1.DVD.disk
echo ^</discstub^> >>"%1.DVD.disk

now do:

Code:
for /f "tokens=*" %%l in (aaa.txt) do call CreateStub.bat "%%l"

or something like that ...

JR
Reply
#3
jhsrennie Wrote:Use two batch files. Create a batch file called CreateStub.bat that does something like:

Code:
rem %1 is the movie name e.g. "The Adjustment Bureau (2010)"
md "%1"
echo ^<discstub^> >"%1.DVD.disk
echo ^<message^>%1 is located in the DVD rack^</message^> >>"%1.DVD.disk
echo ^</discstub^> >>"%1.DVD.disk

now do:

Code:
for /f "tokens=*" %%l in (aaa.txt) do call CreateStub.bat "%%l"

or something like that ...

JR

Well its the something like that part that's got me stumped...LMAO

I messed with that for a few hours and the best I did was it creates a folder for every word not for every line in the file and makes one file out side of the folders with the statement in it....

I'm starting to think it will be faster to do it by hand....LOL

I'm going to post this in some other programing help forums to see if I cant find me a hero. Smile

thanks for trying
Reply
#4
OK I got a working set of scripts. the first one makes the files and the second one creates a folder from the filename and moves the file into it.

Im running into one problem, some of the movies contain an ":" which screws that filename up. I've tried putting a ^ in front of the colon in the text file but this don't help. is there a way to replace it or parse it or clean it in the script?
Reply
#5
Could you post the scripts you used for that ?
I might be able to help you out...
Reply
#6
s1l3nc0r Wrote:Could you post the scripts you used for that ?
I might be able to help you out...

Where were you 17 hour ago.....LMAO

Ok it's complicated just because I was in charge of it....Smile this is my test text file I put a bunch of goofy stuff in it to see if it would fly. everything but the colon goes through. I only make the files with a .dvd extension here cause it was messing me up to have both extensions (dvd.disc)


Code:
(500) Days Of Summer!;2009
6th Day, The;2000
10,000 Bc;2008
11:14;2005
2010: The Year We Make Contact;1984
Brüno;2009
Disney @ Surf's Up;2007
Dolan's & Cadillac;2009


This script takes the names and outputs the files into a subfolder named files.... this is the 30th or 50th thing I tried Im not sure why it works but it does...LOL with the exception of the two names with colons.

Code:
set dir=C:\temp\test\files\
set ext=dvd
for /f "tokens=1,2 delims=;" %%a IN (haa.txt) do >"%dir%\%%~a (%%b).%ext%" (
    echo.^<discstub^>
    echo.^<message^>%%~a is located in the DVD rack^</message^>
    echo.^</discstub^>
)


This file is in the files folder it takes the files appends the .disc ext and moves it into the folder it has just created. Im praying that when I do the whole list of 3000 it don't go bananas Big Grin

Code:
@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
ren *.dvd *.dvd.disc
move "%%a.disc" "%%~na"
)
pause



I'm sure there are better ways to do this and if I spent my time learning to write code instead of chasing women drinking beer and watching movies I'd have more time to watch movies ...Smile



**edit**
well there are other things that mess it up like the u with two dots above it (witch I cant even find on the keyboard..LOL) the ? mark also messes it up and my copy of alien3 the 3 is in subscript that also don't make it through the ringer. but for those three files I can make corrections

I suppose I can just do a search and replace in the text file and get rid of all the miscellaneous crap.
Reply
#7
Muther Wrote:OK I got a working set of scripts. the first one makes the files and the second one creates a folder from the filename and moves the file into it.

Im running into one problem, some of the movies contain an ":" which screws that filename up. I've tried putting a ^ in front of the colon in the text file but this don't help. is there a way to replace it or parse it or clean it in the script?

Try:

Code:
set TITLE=%1 or wherever you get the title from
set TITLE=%TITLE::=%

The general form of the second line is:

set envar=%someenvar:a=b%

and swaps all occurences of a for b in %someenvar%.

JR
Reply
#8
jhsrennie Wrote:Try:

Code:
set TITLE=%1 or wherever you get the title from
set TITLE=%TITLE::=%

The general form of the second line is:

set envar=%someenvar:a=b%

and swaps all occurences of a for b in %someenvar%.

JR


and this will make the colon go away? will doing this on titles that dont contain a colon matter? or should I test for it? I'll mess with it a bit and see if it works.
Thanks
Reply
#9
Code:
D:\temp>set SPLUGH=a:b:c

D:\temp>echo %SPLUGH%
a:b:c

D:\temp>echo %SPLUGH::=%
abc

JR
Reply

Logout Mark Read Team Forum Stats Members Help
Batch file guru needed.0