![]() |
Create a new batch file
Does anyone know how to make a .bat file that will create another .bat file to a specific directory and run a command when opened? Does any one have any ideas? Thanks
|
:
touch /some/dir/newfile |
Maybe I'm jsut retarded here but no matter what I put in "dir" or anywhere I can't get the new file to be created in anything but "C:\" and I want it in "C:\Documents and Settings"
|
@infogeek: I think Steiner is talking windows, not linux.
@steiner: Open a batch file, say 1.bat and put :
echo some command >c:\docume~1\file2.batIf you want to append to the file every time you run 1.bat, use :
echo some command >>c:\docume~1\file2.bat |
thanks alot I'll specify Windows next time, sorry about that
|
What you might want to do is include the whole path c:\dir\me.bat or do cd dir then create it.
|
Quote:
:
echo some command >>c:\docume~1\file2.bat |
Just an aside, if you don't like the artificially shortened version of the directory name, you can actually use spaces in filenames on the command line in recent versions of Windows by surrounding the filename with quotes, like:
:
echo some command >> "C:\Documents and Settings\file2.bat"I haven't tested this (don't have a Windows machine) but it should work. Just remember the quotes have to go around the whole path, not just the parts of it that wouldn't work without them. This works for long filenames and filenames with 'invalid' characters. Off the top of my head, I'm not sure how you include a quote in this; I'd expect doubling up the quotes would do. You probably won't have to do this anyway but I think: :
C:\> echo test > "file with ""quotes"" in name"should create a file called :
file with "quotes" in nameIt might not, but doubling up otherwise invalid characters in strings is usually the way to deal with them on Windows. Hope this helps. |
| All times are GMT -5. The time now is 4:47 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC