Конечно.Вот как написать пакетный скрипт для того, чтобы сделать то, что вам нужно (на Python): сохраните его как runMogrify.py
import os
import string
import fnmatch
source = "c:\\TEST\\import"
target = "c:\\TEST\\export"
def mogrify(parmSource, parmTarget):
mkdirList = []
copyList = []
mogrifyList = []
mkdirList.append('mkdir "' + parmTarget + '"')
for dirpath, dirnames, filenames in os.walk (parmSource):
# print dirpath, dirnames, filenames
for (index,file) in enumerate(sorted(filenames)):
if fnmatch.fnmatch(file.lower(), '*.jpg') or \
fnmatch.fnmatch(file.lower(), '*.gif') or \
fnmatch.fnmatch(file.lower(), '*.bmp'):
sourceFDirPathFile = dirpath + "\\" + file
targetFDirPath = os.path.join (parmTarget, dirpath[1+len (parmSource):])
targetADirPathFile = targetFDirPath + "\\" + str(index+1) + "a" + os.path.splitext(file)[1]
targetBDirPathFile = targetFDirPath + "\\" + str(index+1) + "b" + os.path.splitext(file)[1]
if 'mkdir "' + targetFDirPath + '"' not in mkdirList:
mkdirList.append('mkdir "' + targetFDirPath + '"')
copyList.append('copy "' + sourceFDirPathFile + '" "' + targetADirPathFile + '"')
copyList.append('copy "' + sourceFDirPathFile + '" "' + targetBDirPathFile + '"')
mogrifyList.append('mogrify -resize 400x300 "' + targetADirPathFile + '"')
mogrifyList.append('mogrify -resize 200x150 "' + targetBDirPathFile + '"')
return mkdirList, copyList, mogrifyList
def main():
mkdirList, copyList, mogrifyList = mogrify(source, target)
f = open('RUNMOGRIFY.BAT', 'w')
f.writelines( list("%s\n" % item for item in mkdirList ) )
f.writelines( list("%s\n" % item for item in copyList ) )
f.writelines( list("%s\n" % item for item in mogrifyList) )
f.close()
if __name__=="__main__": main()
И вот результирующий пакетный файл (RUNMOGRIFY.BAT) после того, как я запустил Pythonскрипт выше
в тестовой директории, похожей на вашу:
mkdir "c:\TEST\export"
mkdir "c:\TEST\export\folder1"
mkdir "c:\TEST\export\folder2"
mkdir "c:\TEST\export\folder3"
copy "c:\TEST\import\folder1\a.jpg" "c:\TEST\export\folder1\1a.jpg"
copy "c:\TEST\import\folder1\a.jpg" "c:\TEST\export\folder1\1b.jpg"
copy "c:\TEST\import\folder1\b.jpg" "c:\TEST\export\folder1\2a.jpg"
copy "c:\TEST\import\folder1\b.jpg" "c:\TEST\export\folder1\2b.jpg"
copy "c:\TEST\import\folder1\c.jpg" "c:\TEST\export\folder1\3a.jpg"
copy "c:\TEST\import\folder1\c.jpg" "c:\TEST\export\folder1\3b.jpg"
copy "c:\TEST\import\folder2\a.jpg" "c:\TEST\export\folder2\1a.jpg"
copy "c:\TEST\import\folder2\a.jpg" "c:\TEST\export\folder2\1b.jpg"
copy "c:\TEST\import\folder2\b.jpg" "c:\TEST\export\folder2\2a.jpg"
copy "c:\TEST\import\folder2\b.jpg" "c:\TEST\export\folder2\2b.jpg"
copy "c:\TEST\import\folder2\c.jpg" "c:\TEST\export\folder2\3a.jpg"
copy "c:\TEST\import\folder2\c.jpg" "c:\TEST\export\folder2\3b.jpg"
copy "c:\TEST\import\folder3\a.jpg" "c:\TEST\export\folder3\1a.jpg"
copy "c:\TEST\import\folder3\a.jpg" "c:\TEST\export\folder3\1b.jpg"
copy "c:\TEST\import\folder3\b.jpg" "c:\TEST\export\folder3\2a.jpg"
copy "c:\TEST\import\folder3\b.jpg" "c:\TEST\export\folder3\2b.jpg"
copy "c:\TEST\import\folder3\c.jpg" "c:\TEST\export\folder3\3a.jpg"
copy "c:\TEST\import\folder3\c.jpg" "c:\TEST\export\folder3\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\3b.jpg"