Announcement | We'll be doing maintenance between 2-3 hours, which may impact your experience. Thanks for your patience as we work on improving the community!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
解決済み

Changing file extensions using a Python tool

knozawa
ボリード

Hello,

 

I would like to change a file extension from .zip to .pptx using a python tool in Alteryx.

i.e. "MODIFIED.zip" to "MODIFIED.pptx".

image_3.png

 

Here is the script:

from ayx import Alteryx
import os
from pathlib import Path

directory = ('C:/Temp/PowerPoint test/DELETE_modified/DELETE_original/')

for f in Path(directory).rglob('.zip'):
    f.rename(directory + f.stem + '.pptx')

 

The script runs successfully, but zip file stays the same.

 

3件の返信3
HomesickSurfer
クエーサー

Hi @knozawa 

 

I'm not overly familiar with Python.  Perhaps consider renaming the file extension with a batch script...

danilang
19 - Altair
19 - Altair

Hi @knozawa 

 

Consider using os.rename(src, dst) to change the name.

 

Dan

 

 

knozawa
ボリード

Thank you @HomesickSurfer & @danilang !

 

I updated my script and it successfully updated the extension from .zip to .pptx.

from ayx import Alteryx
import os

directory = ('C:/Temp/PowerPoint test/DELETE_modified/DELETE_original/')

os.rename('MODIFIED.zip', 'MODIFIED.pptx')

 

ラベル
トップのソリューション投稿者