How to multiple different file names without extension to a single folder? e.g
we have two different path name (D:\Folder_1\aa.txt and D:\Folder_2\bb.txt). I want only two filename without extension ($file.BaseName) to the same folder (D:\OtherFolder\aa.csv and ....\bb.csv)
Here is my sample script as below:
$fileList = dir 'D:\Folder_1\aa.txt','D:\Folder_2\bb.txt'
Any Idea? Thanks
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".
Get-ChildItem 'D:\Folder_1\aa.txt','D:\Folder_2\bb.txt' | Copy-Item -Destination 'C:\OtherFolder'
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".
You must be logged in to reply to this topic.