Advertisement
dhniceday

Untitled

Nov 21st, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.37 KB | Software | 0 0
  1. ## Get all pdf
  2.  
  3. ```dataviewjs
  4. const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf')
  5.  
  6. dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
  7. ```
  8.  
  9. ## Get pdf by folder
  10. ```dataviewjs
  11. const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('92 - Rocketbook'))
  12.  
  13. dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
  14. ```
  15.  
  16. ## Get pdf by folder and file name (tag)
  17.  
  18. ```dataviewjs
  19.  
  20. const filter = '[Workflow]'
  21.  
  22. const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('92 - Rocketbook') && file.path.includes(filter))
  23.  
  24. dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
  25. ```
  26.  
  27. ## Get pdf for current note (current file name)
  28.  
  29. ```dataviewjs
  30.  
  31. const filter = '[' + dv.current().file.name + ']'
  32.  
  33. const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('92 - Rocketbook') && file.path.includes(filter))
  34.  
  35.  
  36. dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
  37.  
  38. ```
  39.  
  40. ## Get pdf for studytopic
  41.  
  42. ```dataviewjs
  43. let pg = dv.current()
  44. let studytopic = pg.studytopic.replace(/[%]+/g,'');
  45. dv.span('studytopic: ' + studytopic);
  46.  
  47. const allPdfFiles = app.vault.getFiles().filter(file => file.extension == 'pdf' && file.path.includes(studytopic));
  48.  
  49. dv.list(allPdfFiles.map(file => dv.fileLink(file.path)));
  50.  
  51. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement