#!/usr/bin/env python
# coding: utf-8
# In[32]:
import os
import sys
from os import listdir
from os.path import isfile, join
#if files with no extension, fetch.
vertpath = "D:\BlogBackup\MeduimImg"
vertfiles = [f for f in listdir(vertpath) if isfile(join(vertpath, f))]
for f in vertfiles:
filename, file_extension = os.path.splitext(vertpath+"\\"+f)
if file_extension == '':
fullname = filename+file_extension
print(fullname)
os.rename(fullname.replace("\\","\\\\"),fullname.replace("\\","\\\\")+".png")
# print(fullname.replace("\\","\\\\"))
# print(fullname.replace("\\","\\\\")+".png")
參考來源:
https://stackoverflow.com/questions/51253766/valueerror-embedded-null-character-while-importing-a-json-file-using-python https://datatofish.com/rename-file-python/ https://stackoverflow.com/questions/541390/extracting-extension-from-filename-in-python
Python
Blog
Medium
HackMD
SQL Server Analytics Service 1
SEO(1) Github(2) Title Tag(2) ML(1) 李宏毅(1) SQL Server(18) Tempdb(1) SSMS(1) Windows(1) 自我成長(2) Excel(1) python Flask(1) python(5) Flask(2)
Max Chen (159)