Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create folder from text file

Status
Not open for further replies.

Ruriko

Programmer
Aug 17, 2012
7
I am trying to make a script that will make folders that will read from a text file. In my text file it contains:

Code:
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Imperial Chicken (Fujisaka Kuuki)] OZ (Neon Genesis Evangelion)[Decensored][English]
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Hachiouji Kaipan Totsugeki Kiheitai (Makita Yoshiharu)] Just Want Moyashi! (Nisekoi, Raikkonen no Nettaigyo) (English)
C:\Users\Susan\Documents\iMacros\Downloads\[Shimekiri Sanpunmae (Tsukimi Daifuku)] Ichika I'll Make You Feel Good (Infinite Stratos) (Eng) [Life4Kaoru]
C:\Users\Susan\Documents\iMacros\Downloads\[Nakayohi Mogudan (Mogudan)] Gentei Omakehon 2005.2 (Neon Genesis Evangelion) [ENG] [LWB]
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Kuronishiki (Takaharu)] A.Tsu.I.Yo.Ru (Touhou Project) [English] [CGrascal]
C:\Users\Susan\Documents\iMacros\Downloads\(COMIC1☆6) [Dokuebi. (Antaresu 11)] Despair☠Pirates (Mouretsu Pirates) [English] =LWB=
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Type-G (Ishigaki Takashi)] Ore to NanoFei to One Room (Mahou Shoujo Lyrical Nanoha StrikerS) [English] =TV + Afro=
C:\Users\Susan\Documents\iMacros\Downloads\[Kesshoku Mikan] Cobalt Delphinium (English) (Resident Evil) {doujin-moe.us}
C:\Users\Susan\Documents\iMacros\Downloads\[Clesta (Cle Masahiro)] CL-orz 23 (Kyoukai Senjou no Horizon) [English] [doujin-moe.us]
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Number2 (Takuji)] Datte Aniki wa Nama Ecchi Suki damon (Ore no Imouto ga Konna ni Kawaii Wake ga Nai) [English] [PineApples R' Us + Doujin-Moe.us]
C:\Users\Susan\Documents\iMacros\Downloads\(C82) [Number2 (Takuji)] Damette Ittemo Nakadashi Surundesuyone (Ore no Imouto ga Konna ni Kawaii Wake ga Nai) [English] [PineApples R' Us + Doujin-Moe.us]

This is the script. Can anyone help me fix it?

Code:
dim objFileSys, objReadFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFileSys.OpenTextFile("C:\Users\Susan\Documents\iMacros\Macros\file.txt", ForReading)

Do until objReadFile.AtEndOfStream = True
    objFileSys.CreateFolder(objReadFile.ReadLine)

Loop
objReadFile.Close
Set objReadFile = Nothing
Set objFileSys = Nothing
 
This error
RKkUZ.jpg
 
Hi Ruriko,

does the "Downloads" folder already exist?
You cannot create a folder with a subfolder directly in FSO, you must first create a folder (or make sure it exists) before creating a subfolder in it.

Code:
Set objReadFile = objFileSys.OpenTextFile("C:\Users\Susan\Documents\iMacros\Macros\file.txt", ForReading)
[b]If not objFileSys.FolderExists("C:\Users\Susan\Documents\iMacros\Downloads") then objFileSys.CreateFolder "C:\Users\Susan\Documents\iMacros\Downloads"[/b]
Do until objReadFile.AtEndOfStream = True

Cheers,
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
P.S: I'd recommend using a bit shorter folder names.
Descriptive folder names are perfectly OK but you don't need to put ALL information in them, do you? ;-)

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Another thing - I tried to cut and paste your folder names into a text file to test with, but some of the characters within your folder "C:\Users\Susan\Documents\iMacros\Downloads\(COMIC1☆6) [Dokuebi. (Antaresu 11)] Despair☠Pirates (Mouretsu Pirates) [English] =LWB=" reported as non-ANSI text. When I saved this from notepad as unicode text and then displayed it in the command prompt, those non-ANSI characters displayed as a ? which can not be used as part of a folder name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top