Every line of 'python rename file' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
64 def rename(file, newFileName): 65 DBG("VFS rename({}, {})".format(file, newFileName)) 66 try: 67 os.rename(file, newFileName) 68 except: 69 return False 70 return True
23 def rename(file, newFileName): 24 """Renames a file, returns true/false. 25 26 file: string - file to rename 27 newFileName: string - new filename, including the full path 28 29 Example: 30 success = xbmcvfs.rename(file,newFileName)""" 31 return bool
50 def rename_file(old_filename, new_filename): 51 full_path, filename = os.path.split(old_filename) 52 filename, extension = os.path.splitext(filename) 53 temp_filename = os.path.join(full_path, new_filename + extension) 54 os.rename(old_filename, temp_filename) 55 return temp_filename
111 def rename_file_in_editor(self, old_file, new_file, event=None): 112 self.editor_group.rename_file(old_file, new_file, event=event)
9 def file_rename(addr, x): 10 import os 11 #fname = "/Users/kimseunghyuck/desktop/git/daegon/KYLius-method/승혁/numbers_image/numbers2.jpg" 12 fname=addr 13 frename=os.path.splitext(fname)[0]+str(x)+os.path.splitext(fname)[-1] 14 os.rename(fname, frename) 15 print("파일이름이 {}에서 {}로 변경되었습니다".format(fname, frename))
21 def rename(): 22 relative_filenames = read_file(arguments.input_file) 23 24 index = 0 25 for relative_filename in relative_filenames: 26 if "domain_rgb" in relative_filename: 27 relative_filename = relative_filename.replace("domain_rgb", "domain_depth") 28 input_filename = os.path.join(arguments.input_path, relative_filename) 29 output_filename = os.path.join(arguments.output_path, arguments.output_format.format(index)) 30 shutil.copy(input_filename, output_filename) 31 index += 1
775 def rename(path, newName): 776 """ 777 Renames a file or a directory to newName, in the same folder. 778 779 @since: 1.3 780 781 @type path: string 782 @param path: the docroot-path to the object to rename 783 @type newName: string 784 @param newName: the new name (basename) of the object, including extension, 785 if applicable. 786 787 @rtype: bool 788 @returns: False if newName already exists. True otherwise. 789 """ 790 getLogger().info(">> rename(%s, %s)" % (path, newName)) 791 if not path.startswith('/'): path = '/' + path 792 793 res = False 794 try: 795 res = FileSystemManager.instance().rename(path, newName) 796 except Exception, e: 797 e = Exception("Unable to perform operation: %s\n%s" % (str(e), Tools.getBacktrace())) 798 getLogger().info("<< rename(...): Fault:\n" + str(e)) 799 raise(e) 800 801 getLogger().info("<< rename(): %s" % str(res)) 802 return res
32 def move_file(file_name, new_name): 33 34 print("Moving File '{}' to '{}'".format(file_name, new_name)) 35 36 # Try to rename the file 37 try: 38 os.rename(file_name, new_name) 39 except OSError as e: 40 print("Error moving file") 41 print(e)
337 def rename_filename(filename, new_filename): 338 """ 339 Rename an entry in the Gramps recent items list. 340 """ 341 gramps_rf = RecentFiles() 342 gramps_rf.rename_filename(filename, new_filename) 343 gramps_rf.save()