-2

These Files are containing different file-types. after trying bunch file name changing and using such techniques using cmd this didn't changed. find the screenshot for better understanding.

enter image description here

I've used such code of Python from here but it didn't worked. How to change multiple filenames in a directory using Python

Community
  • 1
  • 1
  • 2
    Welcome to Stack Overflow! It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (console output, stack traces, compiler errors - whatever is applicable). The more detail you provide, the more answers you are likely to receive. – iFlo Dec 22 '16 at 12:29
  • 1
    File extensions won't change what the file actually is. But if you're aware of that, you could use Windows command prompt in that folder: `ren *.* *.jpg` will make the extension on all files to .jpg. Regardless this doesn't seem to be programming related, but if it is, please come back with some code and what steps you have tried. – Iskar Dec 22 '16 at 12:34

2 Answers2

1

You could use os to rename, and glob to conveniently get the list of files:

import os, glob

def rename(files, pattern, replacement):
    for pathname in glob.glob(files):
        basename= os.path.basename(pathname)
        new_filename= basename.replace(pattern, replacement)
        if new_filename != basename:
            os.rename(
              pathname,
              os.path.join(os.path.dirname(pathname), new_filename))

rename('*.XXX', 'XXX', 'YYY')

Inspired in this answer.

Community
  • 1
  • 1
user286089
  • 172
  • 7
0

I've Tried this code in cmd to change file name. but it is changing one file-type at once.

ren [Something].XXX [Something].YYY

Even for changing the file-type of Multiple files in a folder

ren *.XXX *.YYY

But I'm trying to get specifically changing multiple file-types to single file-type. [Some output i've got][1] : https://i.stack.imgur.com/Kdwzx.png