The first problem I notice is that you're not using the file's basename in your out-file command. Therefore in effect what you're passing to the Out-File -FilePath parameter is in effect this: "C:\OtherFolder\.CSV".
Try to create the whole filepath for the new file in one variable and pass that to the -FilePath parameter of Out-File
My assumption from your code is that you're trying to take a tab delimited file and convert it into a CSV, however, have you considered the -Delimeter parameter of Import-Csv? You can copy the files over like this:
Then if you need to import the files into your console use:
#note the backtick (`) before the t
Import-Csv C:\OtherFolder\aa.txt -Delimeter "`t"
EDIT: Actually I may have been hasty to respond. If your input file is delimited by "one space or more" then the "`t" won't work, it needs to be a tab character, so you will still end up having to replace the "once space or more".
Could you share a sample of your input files? I could possibly provide a better solution knowing the structure of the content of the files.
The topic ‘Mulitple Basename(s) to one destination folder’ is closed to new replies.