#*******************************************************************
#Auteur: Casper Limburg
#*******************************************************************
#*******************************************************************
#cleans screen
#*******************************************************************
cls
#*******************************************************************
# Declare variable & constrains
#*******************************************************************
$DirVan = "C:\BestandVerplaatsen\van\*"
$DirNa = "C:\BestandVerplaatsen\naar"
$File = Get-ChildItem $DirVan #| Where-Object {$_.Extension -eq ".txt"}
#*******************************************************************
# if files in directory copy to specific place
#*******************************************************************
foreach ($File in $DirVan){
#If no txt files found...
if (!(gci $DirVan *.txt))
{
write-host "No text files!"
}
#If txt files found...
if (gci $DirVan *.txt)
{
copy-item $DirVan $DirNa -filter "*.txt"
}
# Get Path Extension (hint: there is none!)
$extension = [System.IO.Path]::GetExtension($File)
"GetExtension('{0}') returns '{1}'" -f $DirVan, $extension
if($extension.Length -le 0)
{
#echo file has no extention this will be created now
write-host "The File has no extention, a .tif extention will be made"
## create file extention ?? // HOW ??? HELP !! --> i need to rename a file with no extention in directory $DirVan
}
else
{
write-host "The file is being copied"
copy-item $DirVan $DirNa -filter "*.tif"
}
}