Danbooru

Sorting batch downloaded images?

Posted under General

I've been using that Perl script for downloading a few images, and I find it nice that it skips images it already saved. However, if I wanted to sort the images by putting them in appropriate folders, that would mean the script would redownload every image that isn't in the 'unsorted' folder anymore when it runs again. Are there any alternative ways aside from the obvious 'don't sort them'? Any help or ideas is/are appreciated.

Updated

I've always had problems with hierarchical sorting (which you are required to do when you sort by file folder). You can say sort by series / character, by artist, or by genre, but not any two at once. Moreover if an image would fall into two folders, you end up in a weird situation.

Perhaps you might consider a system that allows you to sort by tags like Danbooru uses on your PC, whilst keeping the images physically in the original location? That would solve both the issues with hierarchical sorting and with needing to keep all your images in one place to prevent re-downloading them.

I think you can do this with applications such as ACDSee and Picasa , but it's been a while since I've tried. At this point, I've mostly given up sorting, and let Danbooru do it for me.

Perhaps you might consider a system that allows you to sort by tags like Danbooru uses on your PC, whilst keeping the images physically in the original location?

I tried this using a program named Taggedfrog. It was way more painful than just putting stuff into seperate folders and eventually its own tag database crashed and ended up being unfixable. Maybe Picasa is better at it, though - thanks for the idea.

But is there no way to sort them into folders without having the Perl script start all over again? Something I considered is copying the images to a new folder, and fill the unsorted one with 0-byte files with the same file names as the images, but is there a convenient and fast way to do that?

I found my solution, and you may or may not care, but I'll post it in case someone finds this workaround method useful in some way.
1. Create a listing by running 'dir /b > listing.txt' in a batch file in the art (dump) directory.
2. Paste the listing.txt somewhere else and make a python file in the same (empty) directory (make sure you have Python installed):
fh=open("listing.txt");
for line in fh.readlines():
(space here)line=line[:-1]
(space here)k=open(line, 'w');
(space here)k.write("w");
(space here)k.close();
The result is thousands of fake image files with the same names as your art - now you can paste your art somewhere safe and replace it with the fake files which are a few bytes (the actual size for 22k+ files was around 25kb, but the size on disk was ~95mb - still hundreds of times smaller than the original images). Your Perl script will skip those files now and you can sort them to folders in peace.
(Make sure the last file in the listing.txt has an enter/newline behind it or it might skip that due to shitty coding)

Again, this method is hardly convenient, but it worked for me and it's here just in case. plzdontflamemethx

Updated

About three years ago there was a python script that did the same thing as that Perl one (it's actually linked to at the beginning of post #16341). I used to use it, but it's no longer compatible with Danbooru, and it was never updated.

It took care of duplicate downloads by maintaining it's own mini sqllite database. I'm not real good with PERL, so I don't know if something similar to that could be implemented with the current script, but it's a more elegant solution than having a bunch of 0k files that you'd need to weed out when doing any sorting.

You can always sort them by filesize, any images you have are bound to be bigger than that bunch of files. But if the perl script kept some database, it would be quite a bit more fabulous, indeed.

1