I have my rename code just stuck in a problem
After renaming the file 01.srt to title_movies_01.srt
How is it possible to save a file on above it of it so that it saves a file inside the folder
"names.txt" inside file text
Code:title_movies_01.srt
"subtitle_output" inside folder
Code:01.srt
after renaming
subtitle_output/title_movies_01.srt
Code works but does not save a file in the same folder subtitle_outputCode:import glob import os path_to_images = glob.glob(r"subtitle_output/01.srt") with open('names.txt') as f: for line, file in zip(f, path_to_images): os.rename(file, line.strip())
		
			+ Reply to Thread
			
		
		
		
			
	
	
				Results 1 to 4 of 4
			
		- 
	Last edited by D.LUFFY; 4th Jun 2023 at 09:02. Reason: code change 
- 
	Then why don't you share the solution? It may help someone else in the future. 
- 
	Code:import os f = open('names.txt', 'r') name = f.read().strip("\n") f.close() f = open("path/01.srt", 'r') text = f.read() f.close() os.remove('path/01.srt') f = open(f"path/{name}", "w") f.write(text) f.close()
Similar Threads
- 
  Rename multiple images within folders using text filesBy D.LUFFY in forum ProgrammingReplies: 2Last Post: 23rd May 2023, 23:06
- 
  Panasonic NV-HS800 doesn't output video but does output HiFi audioBy golenman123 in forum RestorationReplies: 2Last Post: 15th Oct 2022, 15:49
- 
  Avidemux: can't set output aspect ratio to 16:9 (output file is always 4:3)By blaq in forum Video ConversionReplies: 2Last Post: 10th May 2019, 12:24
- 
  FFmpeg Multiple OutputBy m00511 in forum Newbie / General discussionsReplies: 7Last Post: 10th Aug 2018, 15:05
- 
  Do D8 camcorders output dv macroblocks through their s-video output?By Bassquake in forum Capturing and VCRReplies: 5Last Post: 1st Aug 2018, 05:37


 
		
		 View Profile
				View Profile
			 View Forum Posts
				View Forum Posts
			 Private Message
				Private Message
			 
 
			
			
 Quote
 Quote