Combine 2 csv files into 1 file single file

On windows , I have 2 csv files that I am attempting to combine into a single csv file. There may be better ways to do this but I was using the dos command

copy file1.csv + file2.csv=file3.csv which works. However when I try to run this command as part of an action script I cannot seem to make it work as I think relevance’s copy command is being used.

I have tried variations of the following but I cannot get it to work. I run two previous scripts in this same action that creates the first two files and those exist.

// create account4.vbs
createfile until __the_end

dos copy c:\windows\CIP1accounts.csv + c:\windows\CIP2accounts.csv = c:windows\CIPcombined.csv

__the_end

delete {parameter “scriptPath”}\account4.vbs
move __createfile {parameter “scriptPath”}\account4.vbs
waithidden cmd.exe /C cscript //B {parameter “scriptPath”}\account4.vbs

By the way if there is a better way to do this that is great.

That doesn’t look like vbs or anything that I can tell?

Does just the actionscript command

dos copy c:\windows\CIP1accounts.csv + c:\windows\CIP2accounts.csv = c:windows\CIPcombined.csv

work at all? This would replicate what you can do on the command line.

The actionscript dos command will make whatever the remaining command is into a command request

actually if I just run this command from the windows directory from the command line this works

copy CIP1accounts.csv + CIP2accounts.csv = CIPcombined.csv

Again I am not opposed to using another method either if there is a suggestion.

I would think it would be easier to use ‘type’ if you’re using command prompt?

dos type file1.csv file2.csv > file3.csv

I just tried this and I get exit code 1 as I did running the copy command. when I run both commands from the command prompt they work. However in the script they don’t as I get exit code 1

from the windows directory which works.
type CIPCombinedaccounts1.csv CIPCombinedaccounts2.csv > CIPcombined.csv

From the script
// create account4.vbs
createfile until __the_end

dos type c:\windows\CIPCombinedaccounts1.csv c:\windows\CIPCombinedaccounts2.csv > c:windows\CIPcombined.csv

__the_end

delete {parameter “scriptPath”}\account4.vbs
move __createfile {parameter “scriptPath”}\account4.vbs
waithidden cmd.exe /C cscript //B {parameter “scriptPath”}\account4.vbs

Log results
Command succeeded (Exit Code=0) waithidden cmd.exe /C cscript //B C:\BigFixScripts\account3.vbs (action:4833)
Command succeeded createfile until __the_end (action:4833)
Command succeeded delete C:\BigFixScripts\account4.vbs (action:4833)
Command succeeded move __createfile C:\BigFixScripts\account4.vbs (action:4833)
Command started - waithidden cmd.exe /C cscript //B C:\BigFixScripts\account4.vbs (action:4833)
Command succeeded (Exit Code=1) waithidden cmd.exe /C cscript //B C:\BigFixScripts\account4.vbs (action:4833)

I copied your script and didn’t notice it had a backslash missing on this part which keeps getting copied c:windows\CIPcombined.csv

Additionally you DON’T need a createfile… the ENTIRE actionscript body would just be:

dos type c:\windows\CIPCombinedaccounts1.csv  c:\windows\CIPCombinedaccounts2.csv > c:\windows\CIPcombined.csv

Yes I just noticed as well. However I ran it has you and jmaple recommended and it works great. thanks for sticking with me . Success.

Another option in native actionscript -

delete __createfile
createfile until EOF_EOF_EOF
{concatenation "%0d%0a" of lines of file "c:\windows\CIP1accounts.csv"}
{concatenation "%0d%0a" of lines of file "c:\windows\CIP2accounts.csv"}
EOF_EOF_EOF
delete c:\windows\CIPcombined.csv
copy __createfile c:\windows\CIPcombined.csv
2 Likes

Thanks Jason for adding this as an alternative to using the dos command as that worked.

For future reference, another approach you can take here is to use something like:

delete R:\temp\CIPcombined.csv
wait cmd.exe /C copy /b R:\temp\CIP*.csv R:\temp\CIPcombined.csv

Here’s a link describing the /b argument for copy: https://support.microsoft.com/en-us/kb/71161

1 Like