Переход на Linux - переписываем вспомогательные скрипты |
option explicit const DIR = "D:\TorrentDownload\00-to sort" const EXT = " \avi\mkv\mp4\flv\wmv\asf\mov\ts\" dim oFSO: set oFSO=CreateObject("Scripting.FileSystemObject") dim oTargetDIR: set oTargetDIR = oFSO.GetFolder( DIR ) dim oFile dim sExt dim sDirName for each oFile in oTargetDIR.Files sExt = LCase(oFSO.GetExtensionName(oFile.Name)) if InStr( EXT, "\" & sExt & "\") > 0 Then sDirName = DIR & "\" & trim(oFSO.GetBaseName(oFile.Name)) If Not (oFSO.FolderExists( sDirName ) or oFSO.FileExists( sDirName )) Then oFSO.CreateFolder sDirName oFile.Move sDirName & "\" & oFile.Name End If end if next MsgBox "Done"
#! /usr/bin/env python import os, re targetFolder = 'd:\!test' # CHANGE THIS! ext = re.compile(r"^.+\.(?:avi|mov|mp4|mkv|wmv|asf|ts|m2ts|mpg|mpeg)$",re.IGNORECASE + re.UNICODE) print 'Processing ' + targetFolder for fileName in os.listdir(targetFolder): filePath = os.path.join( targetFolder, fileName ) if os.path.isfile( filePath ): if ext.match( fileName ): dirPath = os.path.join(targetFolder,(os.path.splitext(fileName)[0]).strip()) if not os.path.exists( dirPath ): os.mkdir( dirPath ) os.rename( filePath, os.path.join( dirPath, fileName ) ) print 'Done!'
Рубрики: | жисть девелопмент всячина |
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |