2016-04-09 18 views
0

Öğrenci çalışmasını düzenlerken hayatımı biraz daha kolaylaştırmak istiyorum. Automator/Applescript'te doğru iş akışını bulmaya çalışıyorum.PDF'yi ve adını CSV'den kopya olarak kopyalayın ve klasörler oluşturun

CSV LİSTESİ:

  • Öğrenci A
  • Öğrenci B
  • Öğrenci C

PDF Dosyası: MarkScheme.pdf İşte

ne istiyorsunuz gerçekleşmesi için:

  1. 'MarkScheme-studentâ'

nihai klasör adında 'studentâ'

  • Kopya Olarak her klasörün içine PDF dosyasını adlı CSV dosyası her öğrenci, için bir klasör oluşturun (için her bir öğrenci aşağıdaki gibi olmalıdır:

     
    - StudentA 
    -- MarkScheme-StudentA.pdf 
    - StudentB 
    -- MarkScheme-StudentB.pdf 
    - StudentC 
    -- MarkScheme-StudentC.pdf 
    
    

    Bunu başarmanın en iyi yolu nedir? Çok teşekkürler.

  • cevap

    1

    Applescript feryat sizin istediğinizi yapar.

    set FCsv to choose file with prompt "Select your CSV file with students" 
    set Dest to choose folder with prompt "Select master folder" 
    set FPDF to choose file with prompt "Select your PDF file" 
    tell application "Finder" to set PdfName to name of FPDF 
    set PdfName to text 1 thru ((offset of ".pdf" in PdfName) - 1) of PdfName -- get PDF name without .pdf extension 
    
    set Fcontent to read FCsv -- read all cvs file 
    set FLines to every paragraph of Fcontent 
    repeat with aStudent in FLines -- loop through each line of the cvs file 
    tell application "Finder" 
        try -- try to create folder Student in master folder : assumption, it does not exist before ! 
         set SubFolder to make new folder in Dest with properties {name:aStudent} 
        end try 
        set SFolder to SubFolder as string 
        -- use 'cp' shell command to copy with new name 
        do shell script "cp " & (quoted form of (POSIX path of FPDF)) & " " & (quoted form of ((POSIX path of SFolder) & PdfName & "-" & aStudent & ".pdf")) 
    end tell 
    end repeat 
    
    +0

    Teşekkür çok:

    bunu açıklığa kavuşturmak bazı yorumlar ekledi. Tam ihtiyacım olan gibi çalışır! –

    İlgili konular