Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Book List to Folders
#1
Code: (Select All)
$CONSOLE:ONLY
WIDTH 150, 50

'get file lists
SHELL "dir /b z:\ > z:\temp.txt"
_DELAY 2
CHDIR "z:\"

'create directory and place file in them
OPEN "temp.txt" FOR BINARY AS #1
DO
LINE INPUT #1, filename$
IF filename$ = "temp.txt" THEN _CONTINUE
PRINT filename$; " =>";
IF _FILEEXISTS(filename$) THEN
period = _INSTRREV(filename$, ".")
IF period THEN
file_no_ext$ = LEFT$(filename$, period - 1)
ELSE
file_no_ext$ = filename$
END IF
ELSE
PRINT "File not found. Check paths for error."
_CONTINUE
END IF
dash = INSTR(file_no_ext$, " -")
IF dash THEN file_no_ext$ = LEFT$(file_no_ext$, dash - 1)
IF _DIREXISTS(file_no_ext$) = 0 THEN MKDIR file_no_ext$
NAME filename$ AS file_no_ext$ + "\" + filename$
PRINT file_no_ext$ + "\" + filename$
LOOP UNTIL EOF(1)

SYSTEM

As is, I doubt this program will ever be of use to anyone except myself, but I thought I'd share it, in case anyone else ever has a need such as this one.

What this does is solve a massive disk organizational issue for me. As you guys might know, I'm a massive digital packrat. I collect everything -- and lots of everything. (Currently around 80TB of disk storage at my house, and before another year passes, I'll probably end up adding another drive to the mix!)

One thing I've very particular about collecting is e-books. I just love them. Can't get enough of them. Even if it's a book I won't read (such as romance), if I can grab a copy of it in digital form, then I'm going to snatch it and add it to my collection. Since I'm so particular about collecting these books, I want all my books to be able to fit into a nice directory structure so I can navigate and find what I need easily and quickly.

Unfortunately, when you download torrents of books, they're often just in file lists and not in any sort of directory structure. /blah!

This little program, as short as it is, fixes that issue!

BEFORE:
   


AFTER:
   

Others may find something like this useful, so I thought I'd share it so they could refer to this if they ever need to. As it is, unless you have a drive Z: (it's my RAM Drive for quick and dirty temp stuff, such as this, so I won't mess up the originals until I know it all is working 100% right.), this isn't going to do much for you except error out.

The books here are formatted with <Author Name> - <Series> - <Book Name> <.extension>. I use this to strip down to just <Author Name>, then make a directory with that name (if it doesn't already exist), and then move the book into that directory, where they're all together and easy to find and reference in the future.

Simple, and yet *THIS* is probably the best type of example of what I could ever say programming is for. Automate a task that might take days/weeks to be done manually, and let the machine do it in moments!

LONG LIVE QB64PE! Big Grin
Reply
#2
Interesting program. I have this "bookmarked". I probably have one EPUB file. Discovered this file format in another technical forum. :/ Otherwise an user probably seeks to convert it to PDF.

An awful lot of Trac(y|i|ie) in there for the book authors in the screenshot. It's a good thing that name isn't actually this one:

https://en.wikipedia.org/wiki/Karen_(slang)

That would have been the end of a large crowd of book writers for Internet.

Hmm that _DELAY command where it is.
Reply
#3
That delay is to make certain that windows has finished writing the temp.txt file with the file names to the disk, and doesn't have any of it remaining in a buffer still.  Wink
Reply
#4
(11-27-2023, 11:11 AM)mnrvovrfc Wrote: Interesting program. I have this "bookmarked". I probably have one EPUB file. Discovered this file format in another technical forum. :/  Otherwise an user probably seeks to convert it to PDF.

An awful lot of Trac(y|i|ie) in there for the book authors in the screenshot. It's a good thing that name isn't actually this one:

https://en.wikipedia.org/wiki/Karen_(slang)

That would have been the end of a large crowd of book writers for Internet.

Hmm that _DELAY command where it is.

Not that many Karen's?  You must not read much!

   
Reply
#5
I detest eBooks but I like this simple solution for generating a folder for each author.
Tread on those who tread on you

Reply
#6
Kinda puts a new definition to a coding library.
Reply




Users browsing this thread: 4 Guest(s)