Adapté el script publicado por apple16 arriba para ejecutarlo en Python 3 y lo mejoré un poco. Usando una combinación de excluir selectivamente las carpetas del Historial de archivos y este script para ver posibles problemas, acoté mi problema a dos archivos con nombres casi idénticos en el mismo directorio. Ambos archivos tenían la palabra Español en el nombre del archivo con una tilde sobre la n. Sin embargo, uno tenía la codificación como: Espan \ N {COMBINANDO TILDE} ol y el otro como Espa \ N {LATINA PEQUEÑA LETRA N CON TILDE} ol. Ambos nombres de archivo se enumeran de forma idéntica en el Explorador de Windows con la tilde sobre la n. Cuando coloco estos dos archivos en carpetas separadas, el Historial de archivos los respalda muy bien, pero cuando están en el mismo directorio parecen interferir entre sí y bloquean la operación del Historial de archivos.
Aquí está el script CheckFileNames.py que utilicé:
#CheckFileNames.py, 10 May 2016, LewisN
#Python 3 version adapted and enhanced by LewisN; based on script by apple16 posted on http://superuser.com/
#Scans Windows file system for potentially problematic directories and files affecting File History operation.
#---------------------------------------------------------------------------------
#SET THE FOLLOWING BEFORE RUNNING:
DirectoryTreeToScan = r'C:\Users\<username>'
DaysBackToList = 0 #Number of days back to list. Set to 0 to list all FLAGGED FILES regardless of file dates.
PrintDates = False #Set True to show File Creation and Modification dates.
#You may also want to play with the following settings:
flagDirLen=200
flagFullNameLen=200
# Max filename len on Windows is ~255, but File History adds "F:\FileHistory\<username>\<computer name>\Data" to
# the front the files and a timestamp to the end, so backing off on name lengths flagged to be safe.
# Files with long filenames are actually saved to F:\FileHistory\<username>\<computer name>\Data\$OF and can be
# retrieved using the File History GUI, but you may want to avoid this. Also there may be cases where
# long paths and/or filenames cause errors.
#Notes:
# 1. Filenames with Unicode characters from various languages are also often ok for File History.
# This script exposes these characters so they can be examined for potential problems.
# 2. Filenames with initial dots (also flagged here) are ok for File History (use cmd prompt to edit them).
#---------------------------------------------------------------------------------
import os,string,time,datetime
import sys
validChars="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. #^=!()&,_'-+@%[]{$};`~"
disallowedChars=r'\/:*?"<>|'
# Note that many other characters are also actually allowed. Windows expressly disallows \/:*?"<>|
lastdirheader=''
def PrintDirHeaderIfNeeded():
global lastdirheader
if currdir!=lastdirheader:
print ('===FLAGGED FILES IN DIRECTORY',currdir.encode("ascii","replace").decode()+':')
lastdirheader = currdir
return;
def PrintFileDates():
fname=os.path.join(currdir,filename)
print(' Created: ' + time.ctime(os.path.getctime(fname)) + ', Modified: ' + time.ctime(os.path.getmtime(fname)))
return;
def IsRecent(DaysBack):
fname=os.path.join(currdir,filename)
if DaysBack==0: return True # 0 disables limiting file listings based on file dates
if ((datetime.datetime.now()-datetime.datetime.fromtimestamp(os.path.getctime(fname))).days<DaysBack) or \
((datetime.datetime.now()-datetime.datetime.fromtimestamp(os.path.getmtime(fname))).days<DaysBack):
return True
else: return False;
for currdir,folders,filenames in os.walk(DirectoryTreeToScan):
if len(currdir)>flagDirLen:
print('===DIRLEN>' + str(flagDirLen) + ':', currdir.encode("ascii","replace").decode())
if ''.join([x for x in currdir[2:].replace('\\','') if x in validChars])!=currdir[2:].replace('\\',''):
print('===DIR CHARS+:',currdir.encode("ascii","namereplace").decode())
for filename in filenames:
if (len(currdir)+len(filename)>flagFullNameLen) and IsRecent(DaysBackToList):
PrintDirHeaderIfNeeded()
print(' FULLNAMELEN>' + str(flagFullNameLen) + ':', filename.encode("ascii","replace").decode())
if PrintDates: PrintFileDates()
if ''.join([x for x in filename if x in validChars])!=filename and IsRecent(DaysBackToList):
PrintDirHeaderIfNeeded()
print(' CHARS+:',filename.encode("ascii","namereplace").decode())
if PrintDates: PrintFileDates()
if filename[0:1] == "." and IsRecent(DaysBackToList):
PrintDirHeaderIfNeeded()
print(' INITIAL DOT:',filename.encode("ascii","replace").decode())
if PrintDates: PrintFileDates()
if any(True for x in filename if x in disallowedChars) and IsRecent(DaysBackToList):
PrintDirHeaderIfNeeded()
print(' DISALLOWED (' + disallowedChars + '):',filename.encode("ascii","replace").decode())
if PrintDates: PrintFileDates()