Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Changing file extensions using a Python tool

knozawa
11 - Bolide

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 REPLIES 3
HomesickSurfer
12 - Quasar

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
11 - Bolide

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')

 

Labels
Top Solution Authors