textures unpacker

Hi,
As part of a toolbox I create I want to have a button that put textures together from a scene. The idea is to use external files pack then unpack.
Code:

import bpy

bpy.ops.file.pack_all()
bpy.ops.file.unpack_all(method='USE_LOCAL')

I want to choose the directory path. Is it possible? I guess having a path entry then a “save it all!” button would be great

maybe something like this but that won’ t work :confused:

for img in bpy.data.images: 
if img.users: 
bpy.data.images(img).filepath = '//mytextures/'
bpy.data.images(img).save() 

Yes you can at the start of your code when you pack all:
bpy.ops.file.pack_all()

Search in datas, what textures are packed and his idname.
After unpack all, make a search in that folder of all saved textures to verify and ask with your code where to copy them with a file menu.
And at the end of the copy, erase all first textures in that folder with your code!

Good luck!