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


Messages In This Thread
Book List to Folders - by SMcNeill - 11-27-2023, 10:22 AM
RE: Book List to Folders - by mnrvovrfc - 11-27-2023, 11:11 AM
RE: Book List to Folders - by SMcNeill - 11-27-2023, 11:53 AM
RE: Book List to Folders - by SMcNeill - 11-27-2023, 11:22 AM
RE: Book List to Folders - by SpriggsySpriggs - 11-27-2023, 06:30 PM
RE: Book List to Folders - by Dimster - 11-27-2023, 06:51 PM



Users browsing this thread: 2 Guest(s)