Python Forum
Assign image names in folder to images in other folder.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assign image names in folder to images in other folder.
#7
I want to rename the images in a folder with images in another folder. after trying a while it seems bit tricky.

My images in the source folder looks like the following
Quote:1305031102.175304.png
1305031102.211214.png
1305031102.243211.png
1305031102.275326.png
1305031102.311267.png
1305031102.343233.png
1305031102.375329.png
1305031102.411258.png
1305031102.443271.png
I want to give same names as above to the images in another folder with names as following

Quote:0000000.png
0000001.png
0000002.png
0000003.png

I have tried os.rename as follows

import os
import numpy as np

path= "/home/ujjval/Downloads/rgbd_dataset_freiburg1_xyz/rgb/"
path1="/home/ujjval/Downloads/video-image/data/"

list1=os.listdir("/home/ujjval/Downloads/rgbd_dataset_freiburg1_xyz/rgb/")
list2=os.listdir("/home/ujjval/Downloads/video-image/data/")

list1.sort()
list2.sort()

print(list1);
print(list2);
i=1
print(str(path))

#for file in path:
 #   for files in path1:
        #os.rename(os.path.join(path,file), os.path.join(path1,files))
        #os.rename("/home/ujjval/Downloads/rgbd_dataset_freiburg1_xyz/rgb/"+ str(file), "/home/ujjval/Downloads/video-image/data/"+str(file) +".png" )
Reply


Messages In This Thread
renaming the image files in a folder with the image files in another folder - by ujjwalrathod007 - Sep-01-2018, 04:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  No Script Folder in Python 3.6.2 Download jriemer 6 17,779 Aug-21-2023, 02:34 PM
Last Post: SaWe1995
  Insert images in a folder into dataframe tofi 0 5,477 Dec-14-2018, 08:05 PM
Last Post: tofi
  Batch processing and saving into new folder aeritano 3 5,082 Jun-10-2018, 01:17 AM
Last Post: aeritano
  Backtesting a folder with csv files, problem fiddelush 8 4,900 Mar-13-2018, 11:57 AM
Last Post: fiddelush

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020