1.

Solve : make multiple folders with files from a list file?

Answer»

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


Code: [Select]for /f "tokens=*" %%l in (aaa.txt) do echo %%l > "%%l.dvd.DISC"
 now I'm 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: [Select]<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.Hi Bill...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?If you are not using the Script that was provided to you on the other forum (DosTips.com) you posted this question on please post the code you are using.

ThanksA colon is not allowed in the name of a file or folder on Windows.  So whether or not a batch file can read it, for this purpose it's irrelevant.  You'll need to think of different names! Quote from: Squashman on January 04, 2012, 09:20:02 AM

If you are not using the Script that was provided to you on the other forum (DosTips.com) you posted this question on please post the code you are using.

Thanks


Ok it's complicated just because I was in charge of it.... 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: [Select](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: [Select]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

Code: [Select]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 ...



**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.


**EDIT** I just ran the file through a search and replace program and removed all the illegal charters so all is good. Quote from: Veltas on January 04, 2012, 09:30:49 AM
A colon is not allowed in the name of a file or folder on Windows.  So whether or not a batch file can read it, for this purpose it's irrelevant.  You'll need to think of different names!

Yeah I understand this fact, I was looking for a way to remove them in the batch file on the fly.


Discussion

No Comment Found