[20 / 8 / ?]
Quoted By:
Greetings, I will like some help if someone could help how to rename the generic filename of a dump of images that I have with a .json file that has the description on each image with the tags on it, for example in the first example it is: 9ff92223578b3abbaead3cbc0120c802257dd2fe.jpg : "9ff92223578b3abbaead3cbc0120c802257dd2fe": { "c": 1, "e": "jpg", "i": 26, "r": "s", "s": 0, "t": [ "1:1_aspect_ratio", "pines", "hair", "lowres", "teeth" ] }, "9f265439d28fd062ee43175217ea64b12a3011d6": { "c": 1, "e": "png", "i": 25, "r": "s", "s": 2, "t": [ "rose", "brown_hair", "hair", "pines", "pie", "team", "teeth" ] }, "9b0890dc012dd774e0bd24e7ec6d18593f747c73": { "c": 1, "e": "png", "i": 24, "r": "s", "s": 1, "t": [ "1:1_aspect_ratio", "batman", "crossover", "dc", "lowres",, "teeth" ] }, "9a401a5e27004759ab3d117debe61b0dbadbc0ba": { "c": 1, "e": "png", "i": 23, "r": "s", "s": 2, "t": [ "1:1_aspect_ratio", "book", "crossover", "english_text", "lowres", "text", "yume_nikki" ] } I will really appreciate the help, it can be in nodejs or whatever stuff it can get the work done in this 20k+ image dump
Anonymous
You're not making sense. You want to rename 9ff92223578b3abbaead3cbc0120c802257dd2fe.jpg to what, exactly? And you want to put that other JSON data in the file's EXIF???
Anonymous
>>544132 I have a 20k images dump, they are just named like this: 9ff92223578b3abbaead3cbc0120c802257dd2fe.jpg
9f265439d28fd062ee43175217ea64b12a3011d6.png
9a401a5e27004759ab3d117debe61b0dbadbc0ba.png
The same addon I used to dump this gave me a single .json file with all the tags of each images, I will like help in renaming the images from 9a401a5e27004759ab3d117debe61b0dbadbc0ba.png to somethig like 1:1_aspect_ratio book crossover english_text lowres text yume_nikki.png instead, I will really appreciate the help
Anonymous
>>544134 You got Linux and Python? I can do it, if someone doesn't beat me to it.
Anonymous
>>544155 I have both windows serve and Ubuntu one, here is the thread on /g/ too, if Im too retarded someone already provided it and I dont know to really running it properly in a script so the request will change into halp this idiot run this
>>>/g/66940070 Anonymous
>>544157 Yup, that's about what I would've done (the Python). Thanks for posting the /g/ link.
Anonymous
>>544165 that code alone doesnt work unless Im missing something here which Im obvious doing I guess
Anonymous
>>544169 You're probably running Python 2. It runs in Python 3, but your JSON is not well-formed (doesn't parse).
Anonymous
>>544196 I mean, this is what the addon I ussed to dump the stuff gave me.
https://pastebin.com/anmLaV3V Anonymous
Anonymous
Anonymous
>>544465 I detabed/spaced this after look up on google that error and now its this
Anonymous
>>544481 4chan would let me post this morning so I posted that png. Spaces are important in Python! Your indents must be the same number of characters.
import json
import os
with open('descriptions.json', 'r') as f:
descriptions = json.loads(f.read())
for name in descriptions:
info = descriptions[ name ]
filename = name + '.' + info['e']
os.rename(filename, ''.join(info['t']))
Anonymous
>>544485 Oh I see, yeah I check that and I get it now the theory about it... how is the proper indentation of it though? lol, Im trying what I think it should be and it doesnt run so far
Anonymous
>>544497 Ah, I see 4chan fucking took my spacing out. 4 space indent is standard. Replace "1234" with four spaces.
import json
import os
with open('descriptions.json', 'r') as f:
1234descriptions = json.loads(f.read())
for name in descriptions:
1234info = descriptions[ name ]
1234filename = name + '.' + info['e']
1234os.rename(filename, ''.join(info['t']))
Anonymous
>>544499 Same error as before fampai
Anonymous
>>544499 >>544504 Found what the fuck was missing, a fucking ) at the end of everything, new error though
Anonymous
>>544499 >>544505 I mean, It is some progress for now, now the thing is the script crashes when it doesnt found a file and it is also joining the whole tags together and it is also corrupting the images
Anonymous
Quoted By:
>>544499 btw, in the .json file, the key e: has the file extension
>>544206 Anonymous
Quoted By:
>>544517 Dude, I didn't write it. Don't ask me to defend it.
OSError: [Errno 36] File name too long: '0e3d489eb34071a50a1187f9630210ee43077bb4.png' -> '2boys2girlsblonde_hairbrown_haircrossoverheart_cheekslaser_puppylong_hairmagic_wandmarco_diazmoringmarkpink_hairprincess_ponyheadstar-shaped_pupilsstar_butterflystar_warstom_lucitortongue.png'
I'm just gonna go now...
import json
import os
with open('descriptions.json', 'r') as f:
descriptions = json.loads(f.read())
for name in descriptions:
info = descriptions[ name ]
filename = name + '.' + info['e']
os.rename(filename, ''.join(info['t'])+'.'+info['e'])