Exemple #1
0
	def done(self, next_phase, backup) :
		if self.dst is not None and self.isTop :
			# move to top 
			filetools = FileTools(self.dst, self.dst)
			filetools.move_sub_into('folders')
			filetools.remove_empty()

			# rename folder to just number
			count = 1
			for name in os.listdir(self.dst) :
				name = os.path.join(self.dst, name)
				if not os.path.isdir(name) :
					continue

				dst = os.path.join(self.dst, "{0:02d}".format(count))
				while os.path.exists(dst) :
					count += 1
					dst = os.path.join(self.dst, "{0:02d}".format(count))

				os.rename(name, dst)

			# make 'System' and 'Other' folder
			for name in ['System', 'Other'] :
				name = os.path.join(self.dst, name)
				os.mkdir(name)

			# move dst to next 
			filetools = FileTools(self.dst, os.path.join(next_phase, os.path.basename(self.dst)))
			filetools.safe_move()

			# move src to backup
			filetools = FileTools(self.src, os.path.join(backup, os.path.basename(self.src)))
			filetools.safe_move()
Exemple #2
0
	def get_number(self, path) :
		count = {'jpg':0, 'video':0}
		tool = FileTools(path) 
		tool.remove_empty()

		for root, dirs, files in os.walk(path) :
			for d in dirs :
				d = os.path.join(root, d)

				if os.path.basename(d) not in ['Video', 'System', 'Other'] :
					print('{0} abnomal folder name'.format(d))
					return None

			for f in files :
				f = os.path.join(root, f)

				basename, ext = os.path.splitext(f)
				if re.match('\.(jpg)', ext.lower()) is not None :
					count['jpg']+= 1
				elif FileTools.is_media(f)
					count['video'] += 1
				elif SevenZ.is_archive(f) :
					os.remove(f)
				elif re.match('.*Thumbs.db', f) is not None :
					os.remove(f)
				else :
					print("{0} abnomal".format(f))
					return None

		return count