本文整理汇总了Python中FileUtils.readDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.readDirectory方法的具体用法?Python FileUtils.readDirectory怎么用?Python FileUtils.readDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.readDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findExecutableBaseName
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def findExecutableBaseName(_executableName):
fileList = fu.readDirectory(fu.HamsiManagerDirectory, "file")
for fName in fileList:
if fName.split(".")[0] == _executableName and (
fName.split(".")[-1] in ["py", "py3", "pyw", "exe"] or len(fName.split(".")) == 1):
return fName
if _executableName == "HamsiManager":
for fName in fileList:
if fName.lower() == "hamsi" or (fName.lower().split(".")[0] == "hamsi" and (
fName.lower().split(".")[-1] in ["py", "py3", "pyw", "exe"] or len(fName.split(".")) == 1) ):
return fName
for fName in fileList:
if (fName.lower().split(".")[0].find("hamsi") > -1) and (
fName.lower().split(".")[-1] in ["py", "py3", "pyw", "exe"] or len(fName.split(".")) == 1):
return fName
if uni.isWindows:
return "hamsi.exe"
else:
return "hamsi"
if _executableName == "HamsiManagerInstaller":
for fName in fileList:
if fName.lower() == "install" or (fName.lower().split(".")[0] == "install" and (
fName.lower().split(".")[-1] in ["py", "py3", "pyw", "exe"] or len(fName.split(".")) == 1) ):
return fName
for fName in fileList:
if (fName.lower().split(".")[0].find("install") > -1) and (
fName.lower().split(".")[-1] in ["py", "py3", "pyw", "exe"] or len(fName.split(".")) == 1):
return fName
return None
示例2: emendDirectoryWithContents
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def emendDirectoryWithContents(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if uni.getBoolValue("isShowQuickMakeWindow"):
newEmendedName = str(self.leNewValue.text())
else:
newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
fu.activateSmartCheckIcon()
oldFileName = _path
newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
if newDirName != oldFileName:
fileAndDirectoryNames = fu.readDirectory(newDirName, "fileAndDirectory")
for fileAndDirs in fileAndDirectoryNames:
objectType = fu.getObjectType(fu.joinPath(newDirName, fileAndDirs))
fu.moveOrChange(fu.joinPath(newDirName, fileAndDirs),
fu.joinPath(newDirName, Organizer.emend(fileAndDirs, objectType)), objectType)
if uni.isActiveDirectoryCover and uni.getBoolValue(
"isActiveAutoMakeIconToDirectory") and uni.getBoolValue(
"isAutoMakeIconToDirectoryWhenFileMove"):
fu.checkIcon(newDirName)
if fu.isDir(newDirName):
fu.completeSmartCheckIcon()
Dialogs.show(translate("QuickMake", "Directory And Contents Emended"),
str(translate("QuickMake",
"\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
(Organizer.getLink(_path), Organizer.getLink(newDirName)))
self.close()
except:
ReportBug.ReportBug()
示例3: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def refreshTable(self, _path):
self.values = []
fileAndDirectoryNames = fu.readDirectory(_path, "fileAndDirectory",
uni.getBoolValue("isShowHiddensInFolderTable"))
allItemNumber = len(fileAndDirectoryNames)
uni.startThreadAction()
baseNameOfDirectory = fu.getBaseName(_path)
rowNo = 0
self.setRowCount(allItemNumber)
for baseName in fileAndDirectoryNames:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
content = {}
content["path"] = fu.joinPath(_path, baseName)
content["baseNameOfDirectory"] = baseNameOfDirectory
content["baseName"] = baseName
content.update(details)
self.values.append(content)
newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory")
self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
content["baseNameOfDirectory"])
newBaseName = Organizer.emend(content["baseName"], fu.getObjectType(self.values[rowNo]["path"]))
self.createItem(rowNo, "baseName", newBaseName, content["baseName"])
self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))
self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))
self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))
self.createItem(rowNo, "lastMetadataChanged",
Organizer.getCorrectedTime(content["lastMetadataChanged"]))
if not uni.isWindows:
self.createItem(rowNo, "accessRights", content["accessRights"])
self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"])
self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"])
self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"])
rowNo += 1
else:
allItemNumber -= 1
except:
ReportBug.ReportBug()
allItemNumber -= 1
else:
allItemNumber = rowNo
Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
self.setRowCount(len(self.values)) # In case of Non Readable Files and Canceled process
示例4: updateOldSettings
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def updateOldSettings(_oldVersion, _newVersion):
newSettingsKeys, changedDefaultValuesKeys = [], []
try:
oldVersion = int(_oldVersion)
except:
oldVersion = _newVersion
if oldVersion < 1000:
reFillAll(True)
return newSettingsKeys, changedDefaultValuesKeys
if oldVersion < 1081:
newSettingsKeys = newSettingsKeys + ["isCheckUnSavedValues"]
if oldVersion < 1082:
con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
cur = con.cursor()
cur.execute(str("ALTER TABLE searchAndReplaceTable RENAME TO tmpSearchAndReplaceTable;"))
cur.execute(str(
"CREATE TABLE searchAndReplaceTable ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'label' TEXT,'searching' TEXT,'replacing' TEXT,'intIsActive' INTEGER,'intIsCaseSensitive' INTEGER,'intIsRegExp' INTEGER);"))
cur.execute(str(
"INSERT INTO searchAndReplaceTable(label,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp) SELECT searching,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp FROM tmpSearchAndReplaceTable;"))
cur.execute(str("DROP TABLE tmpSearchAndReplaceTable;"))
con.commit()
newSettingsKeys += ["isCorrectValueWithSearchAndReplaceTable"]
if oldVersion < 1170:
newSettingsKeys += ["maxDeletedDirectorySize"]
if oldVersion < 1190:
changedDefaultValuesKeys += ["applicationStyle", "fileExtensionIs"]
if oldVersion < 1371:
changedDefaultValuesKeys += ["fileExtensionIs"]
if oldVersion < 1372:
changedDefaultValuesKeys += ["packagerUnneededDirectories", "cleanerUnneededDirectories"]
if oldVersion < 1373:
uni.MySettings["AmarokTagSourceTypeAmarokMusicTable"] = "Amarok (Smart)"
uni.MySettings["AmarokTagSourceTypeAmarokCopyTable"] = "Amarok (Smart)"
if oldVersion < 1374:
con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
cur = con.cursor()
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'File/Directory Name', 'baseName');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Directory Name', 'baseName');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Directory', 'baseNameOfDirectory');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Album Artist', 'albumArtist');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'File Name', 'baseName');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Artist', 'artist');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Title', 'title');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Album', 'album');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Track No', 'trackNum');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Year', 'year');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Genre', 'genre');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Comment', 'firstComment');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Lyrics', 'firstLyrics');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Current Cover', 'currentCover');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Source Cover', 'sourceCover');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'Destination Cover', 'destinationCover');")
cur.execute("UPDATE bookmarksOfSpecialTools SET value=REPLACE(value,'albumartist', 'albumArtist');")
con.commit()
if oldVersion < 1375:
con = sqlite.connect(fu.joinPath(fu.pathOfSettingsDirectory, "database.sqlite"))
cur = con.cursor()
cur.execute(
"DELETE FROM completerTable WHERE id NOT IN (SELECT MAX(id) FROM completerTable GROUP BY value,objectName);")
cur.execute(
"DELETE FROM bookmarksOfSpecialTools WHERE id NOT IN (SELECT MAX(id) FROM bookmarksOfSpecialTools GROUP BY value,type);")
cur.execute(
"DELETE FROM bookmarksOfDirectories WHERE id NOT IN (SELECT MAX(id) FROM bookmarksOfDirectories GROUP BY value,type,bookmark);")
cur.execute(
"DELETE FROM searchAndReplaceTable WHERE id NOT IN (SELECT MAX(id) FROM searchAndReplaceTable GROUP BY label,searching,replacing,intIsActive,intIsCaseSensitive,intIsRegExp);")
con.commit()
if oldVersion < 1951:
try:
del uni.MySettings["eyeD3TaggerTypeNameForRead"]
del uni.MySettings["eyeD3TaggerTypeNameForWrite"]
except:
pass
setting().remove("eyeD3TaggerTypeNameForRead")
setting().remove("eyeD3TaggerTypeNameForWrite")
setting().sync()
if oldVersion < 1952:
changedDefaultValuesKeys += ["musicExtensions"]
if oldVersion < 2006:
try:
del uni.MySettings["eyed3TaggerTypeNameForRead"]
del uni.MySettings["eyed3TaggerTypeNameForWrite"]
except:
pass
try:
setting().remove("eyed3TaggerTypeNameForRead")
setting().remove("eyed3TaggerTypeNameForWrite")
setting().sync()
except:
pass
if oldVersion < 2007:
newSettingsKeys += ["preferedTaggerModule"]
if oldVersion < 2008:
for f in fu.readDirectory(fu.joinPath(fu.HamsiManagerDirectory, "Taggers"), "file"):
if f.find("NewEyeD3Tagger") > -1:
fu.removeFile(fu.joinPath(fu.HamsiManagerDirectory, "Taggers", f))
return newSettingsKeys, changedDefaultValuesKeys
示例5: getBackupRecordsList
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def getBackupRecordsList():
if fu.isDir(fu.oldRecordsDirectoryPath):
return fu.readDirectory(fu.oldRecordsDirectoryPath, "file")
else:
return []
示例6: writeContents
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def writeContents(self):
self.changedValueNumber = 0
oldAndNewPathValues = []
isNewDirectoriesSame = True
isMovedToNewDirectory = False
currentDirectoryPath = ""
newDirectoryPath = ""
startRowNo, rowStep = 0, 1
uni.startThreadAction()
allItemNumber = len(self.values)
Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
for rowNo in range(startRowNo, self.rowCount(), rowStep):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
if self.isRowHidden(rowNo):
fu.removeFileOrDir(self.values[rowNo]["path"])
self.changedValueNumber += 1
else:
baseNameOfDirectory = str(
self.values[rowNo]["baseNameOfDirectory"])
baseName = str(self.values[rowNo]["baseName"])
if (self.isChangeableItem(rowNo, "sourceCover") or
self.isChangeableItem(rowNo, "destinationCover")):
sourcePath = self.values[rowNo]["sourceCover"]
destinationPath = self.values[rowNo]["destinationCover"]
if self.isChangeableItem(rowNo, "sourceCover"):
sourcePath = str(self.item(rowNo, 3).text()).strip()
if self.isChangeableItem(rowNo, "destinationCover"):
destinationPath = str(self.item(rowNo, 4).text()).strip()
if (str(self.item(rowNo,
2).text()) != sourcePath or sourcePath != destinationPath or str(
self.item(rowNo, 2).text()) != destinationPath) or (
str(self.item(rowNo, 2).text()) !=
self.values[rowNo]["currentCover"] and (
str(self.item(rowNo, 2).text()) != sourcePath and str(
self.item(rowNo, 2).text()) != destinationPath)):
if str(self.item(rowNo, 3).text()).strip() != "":
sourcePath = fu.getRealPath(sourcePath,
self.values[rowNo]["path"])
sourcePath = fu.checkSource(sourcePath, "file")
if sourcePath is not None:
if destinationPath != "":
destinationPath = fu.getRealPath(destinationPath,
self.values[
rowNo]["path"])
if sourcePath != destinationPath:
destinationPath = fu.moveOrChange(sourcePath, destinationPath)
else:
destinationPath = sourcePath
fu.setIconToDirectory(self.values[rowNo]["path"],
destinationPath)
self.changedValueNumber += 1
else:
fu.setIconToDirectory(self.values[rowNo]["path"], "")
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
baseNameOfDirectory = str(self.item(rowNo, 0).text())
self.changedValueNumber += 1
isMovedToNewDirectory = True
currentDirectoryPath = fu.getDirName(
self.values[rowNo]["path"])
newDirectoryPath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
baseNameOfDirectory)
self.setNewDirectory(newDirectoryPath)
if rowNo > 0:
if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
isNewDirectoriesSame = False
if self.isChangeableItem(rowNo, "baseName", baseName, False):
baseName = str(self.item(rowNo, 1).text())
self.changedValueNumber += 1
newFilePath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
baseNameOfDirectory, baseName)
oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
newFilePath = fu.getRealPath(newFilePath)
if oldFilePath != newFilePath:
oldAndNewPaths = {}
oldAndNewPaths["oldPath"] = oldFilePath
oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
if oldFilePath != oldAndNewPaths["newPath"]:
oldAndNewPathValues.append(oldAndNewPaths)
oldDirName = fu.getDirName(oldFilePath)
if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
fu.checkEmptyDirectories(oldDirName, True, True,
uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
except:
ReportBug.ReportBug()
else:
allItemNumber = rowNo + 1
Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
if len(otherFileNames) > 0:
#.........这里部分代码省略.........
示例7: refreshTable
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
def refreshTable(self, _path):
self.values = []
self.setColumnWidth(6, 70)
self.setColumnWidth(7, 40)
musicFileNames = fu.readDirectory(_path, "music", uni.getBoolValue("isShowHiddensInMusicTable"))
isCanNoncompatible = False
allItemNumber = len(musicFileNames)
uni.startThreadAction()
baseNameOfDirectory = fu.getBaseName(_path)
rowNo = 0
self.setRowCount(allItemNumber)
for baseName in musicFileNames:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
tagger = Taggers.getTagger()
try:
tagger.loadFile(fu.joinPath(_path, baseName))
except:
Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"),
str(translate("FileUtils/Musics",
"\"%s\" : this file has the incorrect tag so can't read tags.")
) % Organizer.getLink(fu.joinPath(_path, baseName)))
if tagger.isAvailableFile() is False:
isCanNoncompatible = True
details = fu.getDetails(fu.joinPath(_path, baseName))
content = {}
content["path"] = fu.joinPath(_path, baseName)
content["baseNameOfDirectory"] = baseNameOfDirectory
content["baseName"] = baseName
content["artist"] = tagger.getArtist()
content["title"] = tagger.getTitle()
content["album"] = tagger.getAlbum()
content["albumArtist"] = tagger.getAlbumArtist()
content["trackNum"] = tagger.getTrackNum()
content["year"] = tagger.getYear()
content["genre"] = tagger.getGenre()
content["firstComment"] = tagger.getFirstComment()
content["firstLyrics"] = tagger.getFirstLyrics()
if tagger.isSupportInfo:
content["length"] = tagger.getLength()
content["bitrate"] = tagger.getBitrate()
content["sampleRate"] = tagger.getSampleRate()
content["mode"] = tagger.getMode()
content["size"] = details[stat.ST_SIZE]
content["lastAccessed"] = details[stat.ST_ATIME]
content["lastModified"] = details[stat.ST_MTIME]
content["lastMetadataChanged"] = details[stat.ST_CTIME]
self.values.append(content)
newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory")
self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
self.values[rowNo]["baseNameOfDirectory"])
newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file")
self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"])
newArtist = Organizer.emend(self.values[rowNo]["artist"])
self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"])
newTitle = Organizer.emend(self.values[rowNo]["title"])
self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"])
newAlbum = Organizer.emend(self.values[rowNo]["album"])
self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"])
newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"])
self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"])
newTrackNum = str(self.values[rowNo]["trackNum"])
self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"])
newYear = Organizer.emend(self.values[rowNo]["year"])
self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"])
newGenre = Organizer.emend(self.values[rowNo]["genre"])
self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"])
newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"])
self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"])
newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"])
self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"])
if tagger.isSupportInfo:
self.createItem(rowNo, "length", content["length"])
self.createItem(rowNo, "bitrate", content["bitrate"])
self.createItem(rowNo, "sampleRate", content["sampleRate"])
self.createItem(rowNo, "mode", content["mode"])
self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))
self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))
self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))
self.createItem(rowNo, "lastMetadataChanged",
Organizer.getCorrectedTime(content["lastMetadataChanged"]))
rowNo += 1
#.........这里部分代码省略.........
示例8: writeContents
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import readDirectory [as 别名]
#.........这里部分代码省略.........
changingTag["firstComment"] = value
Records.add(str(translate("MusicTable", "Comment")),
str(self.values[rowNo]["firstComment"]), value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "firstLyrics", self.values[rowNo]["firstLyrics"],
True, isCheckLike):
value = str(self.item(rowNo, 10).text())
tagger.setFirstLyrics(value)
changingTag["firstLyrics"] = value
Records.add(str(translate("MusicTable", "Lyrics")),
str(self.values[rowNo]["firstLyrics"]), value)
self.changedValueNumber += 1
if len(changingTag) > 1:
changingTags.append(changingTag)
tagger.update()
if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
baseNameOfDirectory = str(self.item(rowNo, 0).text())
self.changedValueNumber += 1
isMovedToNewDirectory = True
currentDirectoryPath = fu.getDirName(
self.values[rowNo]["path"])
newDirectoryPath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
baseNameOfDirectory)
self.setNewDirectory(newDirectoryPath)
if rowNo > 0:
if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
isNewDirectoriesSame = False
if self.isChangeableItem(rowNo, "baseName", baseName, False):
baseName = str(self.item(rowNo, 1).text())
self.changedValueNumber += 1
newFilePath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
baseNameOfDirectory, baseName)
oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
newFilePath = fu.getRealPath(newFilePath)
if oldFilePath != newFilePath:
oldAndNewPaths = {}
oldAndNewPaths["oldPath"] = oldFilePath
oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "file")
if oldFilePath != oldAndNewPaths["newPath"]:
oldAndNewPathValues.append(oldAndNewPaths)
oldDirName = fu.getDirName(oldFilePath)
if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
fu.checkEmptyDirectories(oldDirName, True, True,
uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
except:
ReportBug.ReportBug()
else:
allItemNumber = rowNo + 1
Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags And Informations"), rowNo + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
if self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
if len(otherFileNames) > 0:
answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
str(translate("FileUtils/Musics",
"\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
if answer == Dialogs.Yes:
uni.startThreadAction()
allItemNumber = len(otherFileNames)
for rowNo, fileName in enumerate(otherFileNames):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
if oldFilePath != newFilePath:
oldAndNewPaths = {}
oldAndNewPaths["oldPath"] = oldFilePath
oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
fu.getObjectType(oldFilePath))
if oldFilePath != oldAndNewPaths["newPath"]:
oldAndNewPathValues.append(oldAndNewPaths)
except:
ReportBug.ReportBug()
else:
allItemNumber = rowNo + 1
Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
rowNo + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
fu.checkEmptyDirectories(currentDirectoryPath, True, True,
uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
fu.checkIcon(newDirectoryPath)
if uni.isActiveAmarok and uni.getBoolValue("isMusicTableValuesChangeInAmarokDB"):
import Amarok
from Amarok import Operations
Operations.changeTags(changingTags)
if len(oldAndNewPathValues) > 0:
Operations.changePaths(oldAndNewPathValues, "file")
return True