Exemple #1
0
 def rename(self):
     dst = self.make_new_name()
     if dst is not None and self.src != dst:
         filetools = FileTools(self.src, dst)
         dst = filetools.check_conflict()
         if dst is not None:
             Tools.rename(self.src, dst)
         else:
             print("FileTools check_conflict failed")
Exemple #2
0
	def start(self) :
		print('-'*50, self.name, 'Moving ...', '-'*50)
		for src in self.get_match_files() :
			dst = os.path.join(self.move_to, os.path.basename(src)) 
			ftools = FileTools(src, dst)
			dst = ftools.check_conflict()
			if dst is not None :
				try :
					shutil.move(src, dst)
					print(src, '-->', dst)
				except :
					traceback.print_exc()
Exemple #3
0
	def start(self) :
		print('-'*50, self.name, 'Renaming ...', '-'*50)
		for src in self.get_raw_datas() :
			dst = self.make_new_name(src)
			if dst is None :
				continue

			ftool = FileTools(src, dst)
			dst = ftool.check_conflict()
			if dst is not None :
				try :
					os.rename(src, dst)
					self.result['done'].append('SRC : {0}\nDST : {1}'.format(src, dst))
				except :
					traceback.print_exc()
					self.result['fail'].append('rename fail :\nSRC : {0}\nDST : {1}'.format(src, dst))
Exemple #4
0
	def unzip(self) :
		dst = os.path.splitext(self.src)[0]
		filetools = FileTools(self.src, dst)
		dst = filetools.check_conflict()
		if dst is None :
			return

		os.mkdir(dst)
		sevenz = SevenZ(self.src, dst)
		print("UNZIP : {0} started".format(os.path.basename(self.src)))

		if not sevenz.unzip() :
			# unzip failed
			shutil.rmtree(dst)
			print("UNZIP : {0} fail".format(os.path.basename(self.src)))
			return

		# trance code to jpg 
		mogrify = Mogrify(dst)
		mogrify.start()

		print("UNZIP : {0} done".format(os.path.basename(dst)))

		if not self.isTop :
			try :
				shutil.rmtree(self.src)
			except : 
				print("{0}".format(self.src))

		# run sub folder
		exclude = '(ch|char|bg)'
		for root, dirs, files in os.walk(dst) :
			for name in files :
				path = os.path.join(root, name)
				if SevenZ.is_archive(path) and not re.search(exclude, name) :
					unzipper = Unzipper(path, False)
					unzipper.unzip()

		self.dst = dst