summaryrefslogtreecommitdiff
path: root/texmf-dist/doc/latex/thorshammer/system-scripts/standalone/mkclassFolders.ps1
blob: 7f7fcc3ef661452fd550a6639d87d53b1d2a8eb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$classPath="C:\Users\dpstory\Desktop\Test Folder\target\myClass"
# Create class folders
If ( $args.Length -eq 0 ) {
  Write-Host "A CVS file of the class members is required," `
    "see documentation"
  exit
} else {
  $listName=$args[0]
  if(Test-Path -Path ./$listName.csv) {
    } else {
      Write-Host "Cannot find the file `"$listName.csv`" in the current folder," `
        "check the spelling, do not include the extension."
      exit
  }
}
get-content "$listName.csv" | foreach {
$_ +">_Thor" -Replace ";","," } | Set-Content "commaList.csv"

$argList=@()
get-content "commaList.csv" | %{
# Write-Host "$_"
  $split=$_.split(",")
# Write-Host $split[2]
  $argList+=$split[2]
}
$currentPath=Convert-Path .
cd $classPath
Write-Host "Creating folder structure at `$classPath`"," `
  "with some exceptions"
for ($i=0; $i -lt $argList.length; $i++) {
	$arg=$argList[$i]
	$splitTwo=$argList[$i].split(">")
	$firstName=$splitTwo[0]
	$secondName=$splitTwo[1]
  if ($firstName[0] -eq "*") {
    $arg=$arg.substring(1)
    $msg="Parsing the full path $arg" -Replace ">","/"
    Write-Host $msg
    Write-Host "Creating exceptional folders"
    $firstName=$firstName.substring(1)
#Write-Host "$firstName"
    Write-Host "  Creating folder: $firstName"
    New-Item $firstName -ErrorAction:Ignore -ItemType directory
    $secondName=$firstName+"/$secondName"
#Write-Host "$secondName"
    Write-Host "  Creating folder: $secondName"
    New-Item $secondName -ErrorAction:Ignore -ItemType directory
  } else {
  	$msg="Parsing the relative path $arg" -Replace ">","/"
  	Write-Host $msg
  	Write-Host "  Creating folder: $firstName"
  	New-Item $firstName -ErrorAction:Ignore -ItemType directory
  	cd $firstName
  	Write-Host "  Creating subfolder of $firstName named: $secondName"
  	New-Item $secondName -ErrorAction:Ignore -ItemType directory
  	cd ..
  }
}
cd $currentPath
Remove-Item commaList.csv