Best language for file manipulation and simple windows tasks
Started by
ryurek
, Jun 04 2006 07:51 AM
#1
Posted 04 June 2006 - 07:51 AM
#2
Posted 04 June 2006 - 09:35 AM
Depending on what you want to do, I just use batch scripting for this, or Python or C if the task requires it. So I think you have chosen the right languages.
Batches are ideal for these sorts of tasks in general because they behave as direct system() calls in C. So you can just write commands as though you were typing them into the cmd.exe interface. If you wanted to write a batch that took two arguments and copied the second file to the first file you could do:
copy %2 %1
You have the "if exist" command like you mentioned too.
if exist %1 echo File %1 exists already!
if not exist %1 copy %2 %1
Shell scripting is useful for these sorts of simple tasks. For more complicated tasks (parsing files, string processing, regular expressions, whatever), you'll need to use a scripting language like Python (my personal favorite).
Hope this helps
Batches are ideal for these sorts of tasks in general because they behave as direct system() calls in C. So you can just write commands as though you were typing them into the cmd.exe interface. If you wanted to write a batch that took two arguments and copied the second file to the first file you could do:
copy %2 %1
You have the "if exist" command like you mentioned too.
if exist %1 echo File %1 exists already!
if not exist %1 copy %2 %1
Shell scripting is useful for these sorts of simple tasks. For more complicated tasks (parsing files, string processing, regular expressions, whatever), you'll need to use a scripting language like Python (my personal favorite).
Hope this helps
#3
Posted 04 June 2006 - 10:42 AM
I have actually been getting into batch files a lot more lately but I find the limitations annoying...sending things to a text file then pulling them out instead of just holding a place in memory is annoying...I guess if I get into it a bit more the syntax will come second nature and it'll be easier... But I'm not sure I can do the things I want to with it... for instance virus or spyware removal, if there's a program that needs to be pulled out of the current users doc's and settings folder, I'd just be clueless how to do that in batch...although removing files sure would be a lot easier.....
#4
Posted 04 June 2006 - 12:48 PM
Yes, believe me I understand that...sending things to a text file then pulling them out instead of just holding a place in memory is annoying
It really depends on what you want to do. If you are deleting or copying files batch scripting is ideally optimized for that sort of task. (By the way you can grab the location of the current user's Documents and Settings folder using the environmental variable %homepath%. Check out the environmental variables by typing set at a command prompt --- there is more to them than you might think!)
But yes, for more complicated tasks you will for sure have to graduate to another language.
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users