Reputation: 1619
I have a Powershell script.
$baseFolder = "i:\MyClient\Data\"
$importFolder = "$baseFolder" + "_Import\"
$importFiles = Get-ChildItem -Path $importFolder -filter "*.csv"
if (( $importFiles | Measure-Object ).Count -ne 1 ) {
echo "ERROR: **** Incorrect usage **** "
echo ""
echo "The import folder: " $importFolder " must contain 1, and only 1 CSV file for importing."
} else {
echo "Found 1 file for importing."
#Do the import
}
It checks for 1 CSV file being in the _import folder.
There should only be 1 import file in the folder at a time. This is by design.
The filename can be anything.
I cannot figure out how I can get that filename from Get-ChildItem
into a string so that I can append it to the $baseFolder + $archiveFolder variable (not shown), and move it later on.
Upvotes: 1
Views: 114
Reputation: 1619
I needed to add the -Name
parameter.
$importFileName = Get-ChildItem -Path $importFolder -filter "*.csv" -Name
Upvotes: 2