I have this code which writes some stuff into a file which works perfectly, but before I can use this for something else I need to remove the very last character in the file.
My current code looks like this
for root, dirs, files in os.walk(cwd):
for file in files:
if file.endswith('.blend'):
with open("filepaths","a+") as f:
f.write(f'"{os.path.join(root, file)}",\n')
with open("filepaths", 'rb+') as f:
f.seek(0,2)
size=f.tell()
f.truncate(size-1)
The file that needs to be edited looks like this
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/splash279.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/lib/props/barbershop_pole.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/lib/props/hairdryer.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/lib/chars/pigeon.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/lib/chars/agent.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/lib/nodes/nodes_shaders.blend",
"/home/django/copypaste/cleanup/var/media/admin/cedd0c01-930e-4b43-91de-c45447a8f30f/splash279/tools/camera_rig.blend",
I'm in need of removing the very last character of the file which in this case in the comma, but I can't seem to make it work.