预处理更新
①视频源文件夹内文件移动到AV_Data_Capture文件夹后处理。 ②config.ini内增加[movie][path]设置
This commit is contained in:
parent
bab350e8dd
commit
5a6361897a
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import glob
|
||||
@ -10,6 +10,7 @@ from ADC_function import *
|
||||
import json
|
||||
import shutil
|
||||
from configparser import ConfigParser
|
||||
import fnmatch
|
||||
os.chdir(os.getcwd())
|
||||
|
||||
# ============global var===========
|
||||
@ -18,11 +19,25 @@ version='1.3'
|
||||
|
||||
config = ConfigParser()
|
||||
config.read(config_file, encoding='UTF-8')
|
||||
|
||||
fromPath=config['movie']['path']
|
||||
Platform = sys.platform
|
||||
|
||||
# ==========global var end=========
|
||||
|
||||
def moveMovies(fromPath):
|
||||
movieFiles = []
|
||||
if Platform == 'win32':
|
||||
movieFormat = ["avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||
else:
|
||||
movieFormat = ["AVI", "RMVB", "WMV", "MOV", "MP4", "MKV", "FLV", "TS","avi", "rmvb", "wmv", "mov", "mp4", "mkv", "flv", "ts"]
|
||||
for fm in movieFormat:
|
||||
movieFiles = movieFiles + [os.path.join(dirpath, f)
|
||||
for dirpath, dirnames, files in os.walk(fromPath)
|
||||
for f in fnmatch.filter(files, '*.' + fm)]
|
||||
print(movieFiles)
|
||||
for movie in movieFiles:
|
||||
print("Move file " + movie)
|
||||
shutil.move(movie, os.path.curdir)
|
||||
def UpdateCheck():
|
||||
if UpdateCheckSwitch() == '1':
|
||||
html2 = get_html('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/update_check.json')
|
||||
@ -128,6 +143,7 @@ if __name__ =='__main__':
|
||||
print('[*]=====================================')
|
||||
CreatFailedFolder()
|
||||
UpdateCheck()
|
||||
moveMovies(fromPath)
|
||||
os.chdir(os.getcwd())
|
||||
|
||||
count = 0
|
||||
|
@ -25,3 +25,6 @@ directory=
|
||||
|
||||
[escape]
|
||||
literals=\()
|
||||
|
||||
[movie]
|
||||
path=/root/sort/test
|
||||
|
@ -1,29 +0,0 @@
|
||||
# The video format you want to move.
|
||||
$videoFormatLists=("mp4","wmv")
|
||||
# Source video directory
|
||||
$fromDir="X:\av"
|
||||
# Target video directory(path to AVData)
|
||||
$toDir="X:\AVData"
|
||||
|
||||
function moveVideos ($fromDir, $toDir,$videoFormat) {
|
||||
$list=@(Get-ChildItem -Path $fromDir -Recurse -File -Include "*.$videoFormat" | ForEach-Object {$_.FullName})
|
||||
$list.Length
|
||||
|
||||
# Only one video to move.
|
||||
if ($list.Length -eq 1) {
|
||||
Move-Item $list.Replace("`[","``[").Replace("`]","``]") $toDir
|
||||
# More than one videos to move.
|
||||
} else {
|
||||
for($idx=0; $idx -lt $list.Length; $idx++) {
|
||||
echo "Move file $list[$idx].Replace("`[","``[").Replace("`]","``]") to $toDir"
|
||||
# escapse [ ]
|
||||
Move-Item $list[$idx].Replace("`[","``[").Replace("`]","``]") $toDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Move videos
|
||||
for($idy=0; $idy -lt $videoFormatLists.Length; $idy++) {
|
||||
moveVideos $fromDir $toDir $videoFormatLists[$idy]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user