Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

csv - Can a Batch File Tell a program to save a file as? (If so how)

I am currently trying to automate a file transfer process for work and I am not sure how to have a program save a file.

Currently I have created a working batch to move a log file from the point of creation to the correct folder and rename it to include the date. Then use the start function to open that file. All of this works so far.

Now I need that file which was opened to go File>save as>save

It doesn't need the name changed. The program that opens it only saves as CVS and that is my ultimate goal.

Unless someone knows an easier way to change a log file to a CSV file, I am open to that option as well. In a batch file.

Windows 7 computer

EDIT 1*

Renaming it to a csv using the ren command turns the data to garbage when it opens in excel. Going through the program to make the log a csv makes the data appear in the correct format. I need to know how to tell the program to save as. Since there is no shortcut I think I need a way to tell it to push: altF down down (arrow keys) enter enter

I realize that programs like autoit are capable of preforming the function but they are not going to be an option due to restraints with company computers.

Further Research lead me to this post: Press Keyboard keys using a batch file But I am unable to find a way to make this idea work for my case. Maybe it will give someone to go off of though that understands it more.

EDIT 2* This looks like it might get ugly but if anyone understands this as well it could prove very useful for what I need. https://msdn.microsoft.com/en-us/library/8c6yea83.aspx

EDIT 3* Sorry for the broad question but thanks for your assistance.

The BAT so far is pretty simple:

Move /-y "C:UsersxxxDesktopASI Test FolderStation 5Station 5 LogStation 5 Log.log" "O:LABASILogs by DateWeek 2015-4-13"

ren "O:LABASILogs by DateWeek 2015-4-13Station 5 Log.log" "Station 5 Log %date:~4,2%-%date:~7,2%-%date:~10,4%.log"

start "" "C:UsersxxxDesktopASI Test FolderStation 5Station 5 LogStation 5 log.log

pause


I am trying to send keys to RSView to have it save the program. This will make it a CSV that can be opened as an EXCEL doc where I already created a macro that converts that data into a more readable/chartable format.

If We can save this as a CSV I can use the start command again to open it in excel then run the macro.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should be able to use command line switches to do this, instead of ever opening the file. http://plcview.blogspot.com/2012/03/rsview-enterprise-file-viewer-utility.html

"RSView Enterprise File Viewer.exe" /md process.log process.csv


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...