下面的腳本基本上選擇一個帶有PDF的文件夾,獲取所選文件夾的PDF文件數,將結果寫入文本文件,在Excel中打開文本文件。腳本工作正常,但我得到整個文件路徑。帶文件路徑信息到•和/文本項目分隔符
結果是:
/Volumes/PREPRESS/1_CATALOG/2_Press/PRINT_Catalog/2012/•CUSTO_4/BODY/: 65
/Volumes/PREPRESS/1_CATALOG/2_Press/PRINT_Catalog/2012/•CUSTO_4/BODY/: RESENDS 0
/Volumes/PREPRESS/1_CATALOG/2_Press/PRINT_Catalog/2012/•CUSTO_4/COVERS/: 23
/Volumes/PREPRESS/1_CATALOG/2_Press/PRINT_Catalog/2012/•CUSTO_4/COVERS/: RESENDS 6
我想要去除之前子彈•一切都那麼對於每/列。事情是這樣的:
CUSTO_4 BODY 65
CUSTO_4 BODY RESENDS 0
CUSTO_4 COVERS 23
CUSTO_4 COVERS RESENDS 6
我試圖把握文本項分隔符的概念,並使用偏移命令,但我不知道如何實現其寫入腳本。
集TARGET_FOLDER選擇具有提示的文件夾「選擇目標僅包含PDF文件計算文件的文件夾」與允許在沒有隱形 的結果集,以多項選擇「」
repeat with i from 1 to (count target_folder)
set thisFolder to (POSIX path of item i of target_folder)
--Find & count all PDFs in folders selected that DON'T starts with letter R
set fileCount to do shell script "find " & quoted form of thisFolder & " -type f -name *.pdf -and -not -iname 'R[0-9-_]*.pdf' | wc -l"
set results to (results & "" & thisFolder & ":" & fileCount & return)
--Find & count all PDFs in folders selected that starts with letter R
set fileCount to do shell script "find " & quoted form of thisFolder & " -type f -iname 'R[0-9-_]*.pdf' | wc -l"
set results to (results & "" & thisFolder & ":" & tab & tab & "RESENDS" & fileCount & return)
end repeat
--write results to a txt file
set theFilePath to (path to desktop folder as string) & "PDF File Count.txt"
set theFile to open for access file theFilePath with write permission
try
set eof of theFile to 0
write results to file theFilePath
close access theFile
on error
close access theFile
end try
--Will open the the PDF File Count.txt in Excel
tell application "Microsoft Excel"
activate
open text file filename "PDF File Count.txt"
end tell
Red_Menace&adayzdone。感謝你的回覆。他們真的幫助我更好地理解了一點。我決定使用do shell腳本,因爲我可以用更少的代碼實現我想要的。 – nellbern 2012-04-24 20:12:45