私は非常に長いファイル名を持つポッドキャストをダウンロードし、都市名、日付、時間 (1 時間目、2 時間目、3 時間目を意味する) だけになるようにそれらを削除しています。os.rename(file, new_name) を除いて、すべて機能しているように見えます。ここでは、Windows がファイルにアクセスできないことがわかります。
import re, os, glob
from ID3 import *
for files in glob.glob("f:\\Download\*podcasts*"):
os.chdir(files)
for file in os.listdir("."):
if re.search("\A[1-3].",file): # original filenames begin with 1.,2. or 3.
tags=ID3(file)
date = re.search("\w*.-\w*.-\w*.",file) # filenames contain date in MMM-DD-YYYY
date_clean = date.group(0).strip()
hour = re.search("hr\d", file) # file names also contain hr. 1,2 or 3 at end
hour_clean = hour.group(0).strip()
tags['ARTIST'] = "Portland Podcast"
tags['TITLE'] = date_clean + hour_clean
new_name = "Portland-" + date_clean + "-" + hour_clean +".mp3"
print "Changing",file,"to",new_name+"."
os.rename(file,new_name)
os.chdir("F:\\Download")
os.getcwd()
os.system("pause")